1 /* -*-comment-start: "//";comment-end:""-*-
2 * Mes --- Maxwell Equations of Software
3 * Copyright © 2016,2017 Jan Nieuwenhuizen <janneke@gnu.org>
5 * This file is part of Mes.
7 * Mes is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or (at
10 * your option) any later version.
12 * Mes is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Mes. If not, see <http://www.gnu.org/licenses/>.
22 SCM fdisplay_ (SCM, int);
24 SCM display_helper (SCM x, int cont, char* sep, int fd);
27 display_helper (SCM x, int cont, char* sep, int fd)
30 if (g_depth == 0) return cell_unspecified;
31 g_depth = g_depth - 1;
38 fputc (VALUE (x), fd);
43 fputs ("#<procedure ", fd);
45 if (FUNCTION (x).name != 0)
46 p = FUNCTION (x).name;
49 fputs (itoa (CDR (x)), fd);
57 fputs ("#<macro ", fd);
58 display_helper (cdr (x), cont, "", fd);
64 fputs (itoa (VALUE (x)), fd);
69 if (!cont) fputs ("(", fd);
70 if (x && x != cell_nil) fdisplay_ (CAR (x), fd);
71 if (CDR (x) && TYPE (CDR (x)) == TPAIR)
72 display_helper (CDR (x), 1, " ", fd);
73 else if (CDR (x) && CDR (x) != cell_nil)
75 if (TYPE (CDR (x)) != TPAIR)
77 fdisplay_ (CDR (x), fd);
79 if (!cont) fputs (")", fd);
87 while (t && t != cell_nil)
89 fputc (VALUE (CAR (t)), fd);
97 fputs (itoa (TYPE (x)), fd);
111 return display_helper (x, 0, "", g_stdout);
115 display_error_ (SCM x)
118 return display_helper (x, 0, "", STDERR);
122 fdisplay_ (SCM x, int fd) ///((internal))
125 return display_helper (x, 0, "", fd);
129 exit_ (SCM x) ///((name . "exit"))
131 assert (TYPE (x) == TNUMBER);
136 xassq (SCM x, SCM a) ///for speed in core only
138 while (a != cell_nil && x != CDAR (a)) a = CDR (a);
139 return a != cell_nil ? CAR (a) : cell_f;