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/>.
37 *p-- = '0' + (x % 10);
50 fdputs (char const* s, int fd)
60 #define putc(x) fdputc(x, STDOUT)
63 fdputc (int c, int fd)
65 write (fd, (char*)&c, 1);
70 SCM fdisplay_ (SCM, int);
73 display_helper (SCM x, int cont, char* sep, int fd)
76 if (g_depth == 0) return cell_unspecified;
77 g_depth = g_depth - 1;
84 fputc (VALUE (x), fd);
89 fputs ("#<procedure ", fd);
91 if (FUNCTION (x).name != 0)
92 p = FUNCTION (x).name;
95 fputs (itoa (CDR (x)), fd);
103 fputs ("#<macro ", fd);
104 display_helper (cdr (x), cont, "", fd);
110 fputs (itoa (VALUE (x)), fd);
115 if (!cont) fputs ("(", fd);
116 if (x && x != cell_nil) fdisplay_ (CAR (x), fd);
117 if (CDR (x) && TYPE (CDR (x)) == TPAIR)
118 display_helper (CDR (x), 1, " ", fd);
119 else if (CDR (x) && CDR (x) != cell_nil)
121 if (TYPE (CDR (x)) != TPAIR)
123 fdisplay_ (CDR (x), fd);
125 if (!cont) fputs (")", fd);
133 while (t && t != cell_nil)
135 fputc (VALUE (CAR (t)), fd);
143 fputs (itoa (TYPE (x)), fd);
145 fputs (itoa (x), fd);
157 return display_helper (x, 0, "", STDOUT);
161 display_error_ (SCM x)
164 return display_helper (x, 0, "", STDERR);
168 fdisplay_ (SCM x, int fd) ///((internal))
171 return display_helper (x, 0, "", fd);
175 exit_ (SCM x) ///((name . "exit"))
177 assert (TYPE (x) == TNUMBER);
182 xassq (SCM x, SCM a) ///for speed in core only
184 while (a != cell_nil && x != CDAR (a)) a = CDR (a);
185 return a != cell_nil ? CAR (a) : cell_f;