mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-16 09:17:35 +02:00
Return the "void" object from I/O functions
Primarily need this to prevent duplicate output in the REPL when calling functions such as (write).
This commit is contained in:
parent
9b6596e146
commit
741835bc49
3 changed files with 12 additions and 12 deletions
|
@ -87,10 +87,6 @@ typedef long tag_type;
|
|||
#define boolean_tag 15
|
||||
#define cvar_tag 16
|
||||
#define vector_tag 17
|
||||
/* TODO: need a type to return from things like
|
||||
(if #f #t) and (write 1) so the REPL will not print
|
||||
anything for them:
|
||||
void_tag */
|
||||
|
||||
#define nil NULL
|
||||
#define eq(x,y) (x == y)
|
||||
|
|
19
runtime.c
19
runtime.c
|
@ -68,6 +68,9 @@ const object boolean_f = &f_boolean;
|
|||
static symbol_type Cyc_191procedure_symbol = {symbol_tag, "procedure", nil};
|
||||
const object quote_Cyc_191procedure = &Cyc_191procedure_symbol;
|
||||
|
||||
static symbol_type Cyc_void_symbol = {symbol_tag, "", nil};
|
||||
const object quote_void = &Cyc_void_symbol;
|
||||
|
||||
/* Symbol Table */
|
||||
|
||||
/* Notes for the symbol table
|
||||
|
@ -323,8 +326,8 @@ object Cyc_display(object x, FILE *port)
|
|||
{object tmp = nil;
|
||||
object has_cycle = boolean_f;
|
||||
int i = 0;
|
||||
if (nullp(x)) {fprintf(port, "()"); return x;}
|
||||
if (obj_is_char(x)) {fprintf(port, "%c", obj_obj2char(x)); return x;}
|
||||
if (nullp(x)) {fprintf(port, "()"); return quote_void;}
|
||||
if (obj_is_char(x)) {fprintf(port, "%c", obj_obj2char(x)); return quote_void;}
|
||||
switch (type_of(x))
|
||||
{case closure0_tag:
|
||||
case closure1_tag:
|
||||
|
@ -403,7 +406,7 @@ object Cyc_display(object x, FILE *port)
|
|||
break;
|
||||
default:
|
||||
fprintf(port, "Cyc_display: bad tag x=%ld\n", ((closure)x)->tag); getchar(); exit(0);}
|
||||
return x;}
|
||||
return quote_void;}
|
||||
|
||||
object dispatch_write_va(int argc, object clo, object cont, object x, ...) {
|
||||
object result;
|
||||
|
@ -437,8 +440,8 @@ static object _Cyc_write(object x, FILE *port)
|
|||
{object tmp = nil;
|
||||
object has_cycle = boolean_f;
|
||||
int i = 0;
|
||||
if (nullp(x)) {fprintf(port, "()"); return x;}
|
||||
if (obj_is_char(x)) {fprintf(port, "#\\%c", obj_obj2char(x)); return x;}
|
||||
if (nullp(x)) {fprintf(port, "()"); return quote_void;}
|
||||
if (obj_is_char(x)) {fprintf(port, "#\\%c", obj_obj2char(x)); return quote_void;}
|
||||
switch (type_of(x))
|
||||
{case string_tag:
|
||||
fprintf(port, "\"%s\"", ((string_type *) x)->str);
|
||||
|
@ -476,7 +479,7 @@ static object _Cyc_write(object x, FILE *port)
|
|||
break;
|
||||
default:
|
||||
Cyc_display(x, port);}
|
||||
return x;}
|
||||
return quote_void;}
|
||||
|
||||
object Cyc_write(object x, FILE *port)
|
||||
{object y = _Cyc_write(x, port);
|
||||
|
@ -486,11 +489,11 @@ object Cyc_write(object x, FILE *port)
|
|||
object Cyc_write_char(object c, object port)
|
||||
{
|
||||
if (obj_is_char(c)) {
|
||||
fprintf(((port_type *)port)->fp, "%c", obj_obj2char(c)); return c;
|
||||
fprintf(((port_type *)port)->fp, "%c", obj_obj2char(c));
|
||||
} else {
|
||||
Cyc_rt_raise2("Argument is not a character", c);
|
||||
}
|
||||
return c;
|
||||
return quote_void;
|
||||
}
|
||||
|
||||
/* Some of these non-consing functions have been optimized from CPS. */
|
||||
|
|
|
@ -224,6 +224,7 @@ extern jmp_buf jmp_main; /* Where to jump to. */
|
|||
extern const object boolean_t;
|
||||
extern const object boolean_f;
|
||||
extern const object quote_Cyc_191procedure;
|
||||
extern const object quote_void;
|
||||
|
||||
/* This section is auto-generated via --autogen */
|
||||
extern const object primitive_Cyc_91global_91vars;
|
||||
|
|
Loading…
Add table
Reference in a new issue