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/>.
26 SCM fdisplay_ (SCM, int);
28 SCM display_helper (SCM x, int cont, char* sep, int fd);
31 display_helper (SCM x, int cont, char* sep, int fd)
34 if (g_depth == 0) return cell_unspecified;
35 g_depth = g_depth - 1;
42 fputc (VALUE (x), fd);
47 fputs ("#<procedure ", fd);
49 if (FUNCTION (x).name != 0)
50 p = FUNCTION (x).name;
53 fputs (itoa (CDR (x)), fd);
61 fputs ("#<macro ", fd);
62 display_helper (cdr (x), cont, "", fd);
68 fputs (itoa (VALUE (x)), fd);
73 if (!cont) fputs ("(", fd);
74 if (x && x != cell_nil) fdisplay_ (CAR (x), fd);
75 if (CDR (x) && TYPE (CDR (x)) == TPAIR)
76 display_helper (CDR (x), 1, " ", fd);
77 else if (CDR (x) && CDR (x) != cell_nil)
79 if (TYPE (CDR (x)) != TPAIR)
81 fdisplay_ (CDR (x), fd);
83 if (!cont) fputs (")", fd);
91 while (t && t != cell_nil)
93 fputc (VALUE (CAR (t)), fd);
101 fputs (itoa (TYPE (x)), fd);
103 fputs (itoa (x), fd);
115 return display_helper (x, 0, "", STDOUT);
119 display_error_ (SCM x)
122 return display_helper (x, 0, "", STDERR);
126 fdisplay_ (SCM x, int fd) ///((internal))
129 return display_helper (x, 0, "", fd);
133 exit_ (SCM x) ///((name . "exit"))
135 assert (TYPE (x) == TNUMBER);
140 xassq (SCM x, SCM a) ///for speed in core only
142 while (a != cell_nil && x != CDAR (a)) a = CDR (a);
143 return a != cell_nil ? CAR (a) : cell_f;