ref: 4531f42eb7ae46af10997d0583d3e3e113e59d1d
parent: f02ba63fa7b86631ccd8d71157dd88e745e7f1cc
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Sun Nov 10 14:13:50 EST 2024
with FL(x) addition, rename some of the builtins/symbols
--- a/builtins.c
+++ b/builtins.c
@@ -23,9 +23,9 @@
BUILTIN("nconc", nconc)
{
if(nargs == 0)
- return FL(FL_NIL);
+ return FL(Nil);
- value_t lst, first = FL(FL_NIL);
+ value_t lst, first = FL(Nil);
value_t *pcdr = &first;
cons_t *c;
int i = 0;
@@ -40,7 +40,7 @@
while(iscons(c->cdr))
c = (cons_t*)ptr(c->cdr);
pcdr = &c->cdr;
- }else if(lst != FL(FL_NIL))
+ }else if(lst != FL(Nil))
type_error("cons", lst);
}
*pcdr = lst;
@@ -61,7 +61,7 @@
return bind;
v = cdr_(v);
}
- return FL(FL_F);
+ return FL(f);
}
BUILTIN("memq", memq)
@@ -74,7 +74,7 @@
if((c = ptr(v))->car == args[0])
return v;
}
- return FL(FL_F);
+ return FL(f);
}
BUILTIN("length", length)
@@ -86,7 +86,7 @@
if(isvector(a))
return fixnum(vector_size(a));
- if(a == FL(FL_NIL))
+ if(a == FL(Nil))
return fixnum(0);
if(iscons(a)){
size_t n = 0;
@@ -140,7 +140,7 @@
{
argcount(nargs, 1);
return (issymbol(args[0]) &&
- iskeyword((symbol_t*)ptr(args[0]))) ? FL(FL_T) : FL(FL_F);
+ iskeyword((symbol_t*)ptr(args[0]))) ? FL(t) : FL(f);
}
BUILTIN("top-level-value", top_level_value)
@@ -176,7 +176,7 @@
{
USED(args);
argcount(nargs, 0);
- value_t lst = FL(FL_NIL);
+ value_t lst = FL(Nil);
fl_gc_handle(&lst);
global_env_list(FL(symtab), &lst);
fl_free_gc_handles(1);
@@ -187,13 +187,13 @@
{
argcount(nargs, 1);
if(issymbol(args[0]))
- return isconstant((symbol_t*)ptr(args[0])) ? FL(FL_T) : FL(FL_F);
+ return isconstant((symbol_t*)ptr(args[0])) ? FL(t) : FL(f);
if(iscons(args[0])){
- if(car_(args[0]) == FL(QUOTE))
- return FL(FL_T);
- return FL(FL_F);
+ if(car_(args[0]) == FL(quote))
+ return FL(t);
+ return FL(f);
}
- return FL(FL_T);
+ return FL(t);
}
BUILTIN("integer-valued?", integer_valuedp)
@@ -201,11 +201,11 @@
argcount(nargs, 1);
value_t v = args[0];
if(isfixnum(v))
- return FL(FL_T);
+ return FL(t);
if(iscprim(v)){
numerictype_t nt = cp_numtype((cprim_t*)ptr(v));
if(nt < T_FLOAT)
- return FL(FL_T);
+ return FL(t);
void *data = cp_data((cprim_t*)ptr(v));
if(nt == T_FLOAT){
float f = *(float*)data;
@@ -212,7 +212,7 @@
if(f < 0)
f = -f;
if(f <= FLT_MAXINT && (float)(int32_t)f == f)
- return FL(FL_T);
+ return FL(t);
}else{
assert(nt == T_DOUBLE);
double d = *(double*)data;
@@ -219,10 +219,10 @@
if(d < 0)
d = -d;
if(d <= DBL_MAXINT && (double)(int64_t)d == d)
- return FL(FL_T);
+ return FL(t);
}
}
- return FL(FL_F);
+ return FL(f);
}
BUILTIN("integer?", integerp)
@@ -231,7 +231,7 @@
value_t v = args[0];
return (isfixnum(v) ||
(iscprim(v) && cp_numtype((cprim_t*)ptr(v)) < T_FLOAT)) ?
- FL(FL_T) : FL(FL_F);
+ FL(t) : FL(f);
}
BUILTIN("bignum?", bignump)
@@ -239,7 +239,7 @@
argcount(nargs, 1);
value_t v = args[0];
return (iscvalue(v) && cp_numtype((cprim_t*)ptr(v)) == T_MPINT) ?
- FL(FL_T) : FL(FL_F);
+ FL(t) : FL(f);
}
BUILTIN("fixnum", fixnum)
@@ -295,7 +295,7 @@
v = alloc_vector((unsigned)i, 0);
a = 1;
for(k = 0; k < i; k++){
- f = a < nargs ? args[a] : FL(FL_UNSPECIFIED);
+ f = a < nargs ? args[a] : FL(unspecified);
vector_elt(v, k) = f;
if((a = (a + 1) % nargs) < 1)
a = 1;
@@ -355,7 +355,7 @@
char *ptr = tostring(args[0]);
if(chdir(ptr))
lerrorf(FL(IOError), "could not cd to %s", ptr);
- return FL(FL_T);
+ return FL(t);
}
BUILTIN("path-exists?", path_existsp)
@@ -362,7 +362,7 @@
{
argcount(nargs, 1);
char *path = tostring(args[0]);
- return access(path, F_OK) == 0 ? FL(FL_T) : FL(FL_F);
+ return access(path, F_OK) == 0 ? FL(t) : FL(f);
}
BUILTIN("os-getenv", os_getenv)
@@ -371,7 +371,7 @@
char *name = tostring(args[0]);
char *val = getenv(name);
if(val == nil)
- return FL(FL_F);
+ return FL(f);
if(*val == 0)
return symbol_value(FL(emptystringsym));
return cvalue_static_cstring(val);
@@ -382,7 +382,7 @@
argcount(nargs, 2);
char *name = tostring(args[0]);
int result;
- if(args[1] == FL(FL_F))
+ if(args[1] == FL(f))
result = unsetenv(name);
else{
char *val = tostring(args[1]);
@@ -390,7 +390,7 @@
}
if(result != 0)
lerrorf(FL(ArgError), "invalid environment variable");
- return FL(FL_T);
+ return FL(t);
}
BUILTIN("rand", rand)
--- a/cvalues.c
+++ b/cvalues.c
@@ -162,7 +162,7 @@
pcv->data = ptr;
pcv->len = sz;
pcv->type = type;
- if(parent != FL(NIL)){
+ if(parent != FL(Nil)){
pcv->type = (fltype_t*)(((uintptr_t)pcv->type) | CV_PARENT_BIT);
pcv->parent = parent;
}
@@ -179,7 +179,7 @@
value_t
cvalue_static_cstring(const char *str)
{
- return cvalue_from_ref(FL(stringtype), (char*)str, strlen(str), FL(NIL));
+ return cvalue_from_ref(FL(stringtype), (char*)str, strlen(str), FL(Nil));
}
value_t
@@ -429,7 +429,7 @@
return vector_size(arg);
if(iscons(arg))
return llength(arg);
- if(arg == FL(NIL))
+ if(arg == FL(Nil))
return 0;
if(isarray(arg))
return cvalue_arraylen(arg);
@@ -462,7 +462,7 @@
}
return 0;
}
- if(iscons(arg) || arg == FL(NIL)){
+ if(iscons(arg) || arg == FL(Nil)){
i = 0;
while(iscons(arg)){
if(i == cnt){
@@ -614,7 +614,7 @@
if(iscons(type)){
value_t hed = car_(type);
if(hed == FL(structsym))
- return cvalue_struct_offs(type, FL(NIL), 1, palign);
+ return cvalue_struct_offs(type, FL(Nil), 1, palign);
if(hed == FL(unionsym))
return cvalue_union_size(type, palign);
if(hed == FL(pointersym) || hed == FL(cfunctionsym)){
@@ -686,15 +686,15 @@
case TAG_SYM: return FL(symbolsym);
case TAG_VECTOR: return FL(vectorsym);
case TAG_FUNCTION:
- if(args[0] == FL(FL_T) || args[0] == FL(FL_F))
+ if(args[0] == FL(t) || args[0] == FL(f))
return FL(booleansym);
- if(args[0] == FL(NIL))
+ if(args[0] == FL(Nil))
return FL(nullsym);
- if(args[0] == FL(FL_EOF))
+ if(args[0] == FL(eof))
return symbol("eof-object");
if(isbuiltin(args[0]))
return FL(builtinsym);
- return FL(FUNCTION);
+ return FL(function);
}
return cv_type(ptr(args[0]));
}
@@ -742,7 +742,7 @@
autorelease(ncv);
if(hasparent(cv)){
ncv->type = (fltype_t*)(((uintptr_t)ncv->type) & ~CV_PARENT_BIT);
- ncv->parent = FL(NIL);
+ ncv->parent = FL(Nil);
}
}else{
ncv->data = &ncv->_space[0];
@@ -768,7 +768,7 @@
argcount(nargs, 1);
return (iscprim(args[0]) ||
(iscvalue(args[0]) && cv_isPOD((cvalue_t*)ptr(args[0])))) ?
- FL(FL_T) : FL(FL_F);
+ FL(t) : FL(f);
}
static void
@@ -1473,7 +1473,7 @@
}
}
assert(0);
- return FL(NIL);
+ return FL(Nil);
}
BUILTIN("logand", logand)
--- a/equal.c
+++ b/equal.c
@@ -23,7 +23,7 @@
{
value_t c = (value_t)ptrhash_get(table, (void*)key);
if(c == (value_t)HT_NOTFOUND)
- return FL(NIL);
+ return FL(Nil);
if(c == key)
return c;
return eq_class(table, c);
@@ -32,8 +32,8 @@
static void
eq_union(htable_t *table, value_t a, value_t b, value_t c, value_t cb)
{
- value_t ca = c == FL(NIL) ? a : c;
- if(cb != FL(NIL))
+ value_t ca = c == FL(Nil) ? a : c;
+ if(cb != FL(Nil))
ptrhash_put(table, (void*)cb, (void*)ca);
ptrhash_put(table, (void*)a, (void*)ca);
ptrhash_put(table, (void*)b, (void*)ca);
@@ -53,7 +53,7 @@
m = la < lb ? la : lb;
for(i = 0; i < m; i++){
value_t d = bounded_compare(vector_elt(a, i), vector_elt(b, i), bound-1, eq);
- if(d == FL(NIL) || numval(d) != 0)
+ if(d == FL(Nil) || numval(d) != 0)
return d;
}
if(la < lb)
@@ -75,7 +75,7 @@
if(a == b)
return fixnum(0);
if(bound <= 0)
- return FL(NIL);
+ return FL(Nil);
int taga = tag(a);
int tagb = cmptag(b);
int c;
@@ -133,13 +133,13 @@
function_t *fa = ptr(a);
function_t *fb = ptr(b);
d = bounded_compare(fa->bcode, fb->bcode, bound-1, eq);
- if(d == FL(NIL) || numval(d) != 0)
+ if(d == FL(Nil) || numval(d) != 0)
return d;
d = bounded_compare(fa->vals, fb->vals, bound-1, eq);
- if(d == FL(NIL) || numval(d) != 0)
+ if(d == FL(Nil) || numval(d) != 0)
return d;
d = bounded_compare(fa->env, fb->env, bound-1, eq);
- if(d == FL(NIL) || numval(d) != 0)
+ if(d == FL(Nil) || numval(d) != 0)
return d;
return fixnum(0);
}
@@ -150,7 +150,7 @@
if(tagb < TAG_CONS)
return fixnum(1);
d = bounded_compare(car_(a), car_(b), bound-1, eq);
- if(d == FL(NIL) || numval(d) != 0)
+ if(d == FL(Nil) || numval(d) != 0)
return d;
a = cdr_(a); b = cdr_(b);
bound--;
@@ -176,7 +176,7 @@
xb = vector_elt(b, i);
if(leafp(xa) || leafp(xb)){
d = bounded_compare(xa, xb, 1, eq);
- if(d != FL(NIL) && numval(d) != 0)
+ if(d != FL(Nil) && numval(d) != 0)
return d;
}else if(tag(xa) < tag(xb))
return fixnum(-1);
@@ -186,7 +186,7 @@
ca = eq_class(table, a);
cb = eq_class(table, b);
- if(ca != FL(NIL) && ca == cb)
+ if(ca != FL(Nil) && ca == cb)
return fixnum(0);
eq_union(table, a, b, ca, cb);
@@ -227,7 +227,7 @@
int tagdb = tag(db);
if(leafp(aa) || leafp(ab)){
d = bounded_compare(aa, ab, 1, eq);
- if(d != FL(NIL) && numval(d) != 0)
+ if(d != FL(Nil) && numval(d) != 0)
return d;
}
if(tagaa < tagab)
@@ -236,7 +236,7 @@
return fixnum(1);
if(leafp(da) || leafp(db)){
d = bounded_compare(da, db, 1, eq);
- if(d != FL(NIL) && numval(d) != 0)
+ if(d != FL(Nil) && numval(d) != 0)
return d;
}
if(tagda < tagdb)
@@ -246,7 +246,7 @@
ca = eq_class(table, a);
cb = eq_class(table, b);
- if(ca != FL(NIL) && ca == cb)
+ if(ca != FL(Nil) && ca == cb)
return fixnum(0);
eq_union(table, a, b, ca, cb);
@@ -271,7 +271,7 @@
ca = eq_class(table, a);
cb = eq_class(table, b);
- if(ca != FL(NIL) && ca == cb)
+ if(ca != FL(Nil) && ca == cb)
return fixnum(0);
eq_union(table, a, b, ca, cb);
@@ -298,7 +298,7 @@
compare_(value_t a, value_t b, int eq)
{
value_t guess = bounded_compare(a, b, BOUNDED_COMPARE_BOUND, eq);
- if(guess == FL(NIL)){
+ if(guess == FL(Nil)){
guess = cyc_compare(a, b, &equal_eq_hashtable, eq);
htable_reset(&equal_eq_hashtable, 512);
}
@@ -315,8 +315,8 @@
fl_equal(value_t a, value_t b)
{
if(eq_comparable(a, b))
- return a == b ? FL(FL_T) : FL(FL_F);
- return numval(compare_(a, b, 1)) == 0 ? FL(FL_T) : FL(FL_F);
+ return a == b ? FL(t) : FL(f);
+ return numval(compare_(a, b, 1)) == 0 ? FL(t) : FL(f);
}
/*
--- a/flisp.c
+++ b/flisp.c
@@ -61,7 +61,7 @@
for(l__tr = 1; l__tr; l__tr = 0, (void)(FL(exctx) = FL(exctx)->prev))
#define FL_CATCH_INC \
- l__ca = 0, FL(lasterror) = FL(FL_NIL), FL(throwing_frame) = 0, FL(SP) = _ctx.sp, FL(curr_frame) = _ctx.frame
+ l__ca = 0, FL(lasterror) = FL(Nil), FL(throwing_frame) = 0, FL(SP) = _ctx.sp, FL(curr_frame) = _ctx.frame
#define FL_CATCH \
else \
@@ -84,7 +84,7 @@
void
fl_restorestate(fl_exception_context_t *_ctx)
{
- FL(lasterror) = FL(FL_NIL);
+ FL(lasterror) = FL(Nil);
FL(throwing_frame) = 0;
FL(SP) = _ctx->sp;
FL(curr_frame) = _ctx->frame;
@@ -229,7 +229,7 @@
BUILTIN("gensym?", gensymp)
{
argcount(nargs, 1);
- return isgensym(args[0]) ? FL(FL_T) : FL(FL_F);
+ return isgensym(args[0]) ? FL(t) : FL(f);
}
char *
@@ -308,7 +308,7 @@
if(init){
unsigned int i;
for(i = 0; i < n; i++)
- vector_elt(v, i) = FL(FL_UNSPECIFIED);
+ vector_elt(v, i) = FL(unspecified);
}
return v;
}
@@ -353,7 +353,7 @@
pcdr = &cdr_(nc);
v = d;
}while(iscons(v));
- *pcdr = d == FL(NIL) ? FL(NIL) : relocate(d);
+ *pcdr = d == FL(Nil) ? FL(Nil) : relocate(d);
return first;
}
@@ -622,7 +622,7 @@
c->cdr = tagptr(c+1, TAG_CONS);
c++;
}
- c[-1].cdr = FL(NIL);
+ c[-1].cdr = FL(Nil);
POPN(n);
va_end(ap);
@@ -640,7 +640,7 @@
c[0].car = a;
c[0].cdr = tagptr(c+1, TAG_CONS);
c[1].car = b;
- c[1].cdr = FL(NIL);
+ c[1].cdr = FL(Nil);
return tagptr(c, TAG_CONS);
}
@@ -689,7 +689,7 @@
if(star)
c[-2].cdr = c[-1].car;
else
- c[-1].cdr = FL(NIL);
+ c[-1].cdr = FL(Nil);
return v;
}
@@ -697,8 +697,8 @@
copy_list(value_t L)
{
if(!iscons(L))
- return FL(NIL);
- PUSH(FL(NIL));
+ return FL(Nil);
+ PUSH(FL(Nil));
PUSH(L);
value_t *plcons = &FL(Stack)[FL(SP)-2];
value_t *pL = &FL(Stack)[FL(SP)-1];
@@ -705,13 +705,13 @@
value_t c;
c = mk_cons(); PUSH(c); // save first cons
car_(c) = car_(*pL);
- cdr_(c) = FL(NIL);
+ cdr_(c) = FL(Nil);
*plcons = c;
*pL = cdr_(*pL);
while(iscons(*pL)){
c = mk_cons();
car_(c) = car_(*pL);
- cdr_(c) = FL(NIL);
+ cdr_(c) = FL(Nil);
cdr_(*plcons) = c;
*plcons = c;
*pL = cdr_(*pL);
@@ -725,7 +725,7 @@
do_trycatch(void)
{
uint32_t saveSP = FL(SP);
- value_t v = FL(NIL);
+ value_t v = FL(Nil);
value_t thunk = FL(Stack)[FL(SP)-2];
FL(Stack)[FL(SP)-2] = FL(Stack)[FL(SP)-1];
FL(Stack)[FL(SP)-1] = thunk;
@@ -752,7 +752,7 @@
{
uint32_t extr = nopt+nkw;
uint32_t ntot = nreq+extr;
- value_t args[64], v = FL(NIL);
+ value_t args[64], v = FL(Nil);
uint32_t i, a = 0, nrestargs;
value_t s1 = FL(Stack)[FL(SP)-1];
value_t s2 = FL(Stack)[FL(SP)-2];
@@ -911,7 +911,7 @@
NEXT_OP;
OP(OP_BRF)
- ip += POP() == FL(FL_F) ? GET_INT16(ip) : 2;
+ ip += POP() == FL(f) ? GET_INT16(ip) : 2;
NEXT_OP;
OP(OP_POP)
@@ -1123,7 +1123,7 @@
NEXT_OP;
OP(OP_PAIRP)
- FL(Stack)[FL(SP)-1] = iscons(FL(Stack)[FL(SP)-1]) ? FL(FL_T) : FL(FL_F);
+ FL(Stack)[FL(SP)-1] = iscons(FL(Stack)[FL(SP)-1]) ? FL(t) : FL(f);
NEXT_OP;
OP(OP_BRNE)
@@ -1132,7 +1132,7 @@
NEXT_OP;
OP(OP_LOADT)
- PUSH(FL(FL_T));
+ PUSH(FL(t));
NEXT_OP;
OP(OP_LOAD0)
@@ -1162,15 +1162,15 @@
NEXT_OP;
OP(OP_ATOMP)
- FL(Stack)[FL(SP)-1] = iscons(FL(Stack)[FL(SP)-1]) ? FL(FL_F) : FL(FL_T);
+ FL(Stack)[FL(SP)-1] = iscons(FL(Stack)[FL(SP)-1]) ? FL(f) : FL(t);
NEXT_OP;
OP(OP_BRT)
- ip += POP() != FL(FL_F) ? GET_INT16(ip) : 2;
+ ip += POP() != FL(f) ? GET_INT16(ip) : 2;
NEXT_OP;
OP(OP_BRNN)
- ip += POP() != FL(NIL) ? GET_INT16(ip) : 2;
+ ip += POP() != FL(Nil) ? GET_INT16(ip) : 2;
NEXT_OP;
OP(OP_LOAD1)
@@ -1182,7 +1182,7 @@
if(x > 1)
x = numval(fl_compare(FL(Stack)[FL(SP)-2], FL(Stack)[FL(SP)-1]));
POPN(1);
- FL(Stack)[FL(SP)-1] = x < 0 ? FL(FL_T) : FL(FL_F);
+ FL(Stack)[FL(SP)-1] = x < 0 ? FL(t) : FL(f);
NEXT_OP;
OP(OP_ADD2)
@@ -1208,7 +1208,7 @@
NEXT_OP;
OP(OP_LOADF)
- PUSH(FL(FL_F));
+ PUSH(FL(f));
NEXT_OP;
OP(OP_CONS)
@@ -1223,16 +1223,16 @@
NEXT_OP;
OP(OP_EQ)
- FL(Stack)[FL(SP)-2] = FL(Stack)[FL(SP)-2] == FL(Stack)[FL(SP)-1] ? FL(FL_T) : FL(FL_F);
+ FL(Stack)[FL(SP)-2] = FL(Stack)[FL(SP)-2] == FL(Stack)[FL(SP)-1] ? FL(t) : FL(f);
POPN(1);
NEXT_OP;
OP(OP_SYMBOLP)
- FL(Stack)[FL(SP)-1] = issymbol(FL(Stack)[FL(SP)-1]) ? FL(FL_T) : FL(FL_F);
+ FL(Stack)[FL(SP)-1] = issymbol(FL(Stack)[FL(SP)-1]) ? FL(t) : FL(f);
NEXT_OP;
OP(OP_NOT)
- FL(Stack)[FL(SP)-1] = FL(Stack)[FL(SP)-1] == FL(FL_F) ? FL(FL_T) : FL(FL_F);
+ FL(Stack)[FL(SP)-1] = FL(Stack)[FL(SP)-1] == FL(f) ? FL(t) : FL(f);
NEXT_OP;
OP(OP_CADR)
@@ -1256,32 +1256,32 @@
NEXT_OP;
OP(OP_NULLP)
- FL(Stack)[FL(SP)-1] = FL(Stack)[FL(SP)-1] == FL(NIL) ? FL(FL_T) : FL(FL_F);
+ FL(Stack)[FL(SP)-1] = FL(Stack)[FL(SP)-1] == FL(Nil) ? FL(t) : FL(f);
NEXT_OP;
OP(OP_BOOLEANP)
v = FL(Stack)[FL(SP)-1];
- FL(Stack)[FL(SP)-1] = (v == FL(FL_T) || v == FL(FL_F)) ? FL(FL_T) : FL(FL_F);
+ FL(Stack)[FL(SP)-1] = (v == FL(t) || v == FL(f)) ? FL(t) : FL(f);
NEXT_OP;
OP(OP_NUMBERP)
v = FL(Stack)[FL(SP)-1];
- FL(Stack)[FL(SP)-1] = fl_isnumber(v) ? FL(FL_T) : FL(FL_F);
+ FL(Stack)[FL(SP)-1] = fl_isnumber(v) ? FL(t) : FL(f);
NEXT_OP;
OP(OP_FIXNUMP)
- FL(Stack)[FL(SP)-1] = isfixnum(FL(Stack)[FL(SP)-1]) ? FL(FL_T) : FL(FL_F);
+ FL(Stack)[FL(SP)-1] = isfixnum(FL(Stack)[FL(SP)-1]) ? FL(t) : FL(f);
NEXT_OP;
OP(OP_BOUNDP)
FL(Stack)[ipd] = (uintptr_t)ip;
sym = tosymbol(FL(Stack)[FL(SP)-1]);
- FL(Stack)[FL(SP)-1] = sym->binding == UNBOUND ? FL(FL_F) : FL(FL_T);
+ FL(Stack)[FL(SP)-1] = sym->binding == UNBOUND ? FL(f) : FL(t);
NEXT_OP;
OP(OP_BUILTINP)
v = FL(Stack)[FL(SP)-1];
- FL(Stack)[FL(SP)-1] = (isbuiltin(v) || iscbuiltin(v)) ? FL(FL_T) : FL(FL_F);
+ FL(Stack)[FL(SP)-1] = (isbuiltin(v) || iscbuiltin(v)) ? FL(t) : FL(f);
NEXT_OP;
OP(OP_FUNCTIONP)
@@ -1289,11 +1289,11 @@
FL(Stack)[FL(SP)-1] =
((tag(v) == TAG_FUNCTION &&
(isbuiltin(v) || v>(N_BUILTINS<<3))) ||
- iscbuiltin(v)) ? FL(FL_T) : FL(FL_F);
+ iscbuiltin(v)) ? FL(t) : FL(f);
NEXT_OP;
OP(OP_VECTORP)
- FL(Stack)[FL(SP)-1] = isvector(FL(Stack)[FL(SP)-1]) ? FL(FL_T) : FL(FL_F);
+ FL(Stack)[FL(SP)-1] = isvector(FL(Stack)[FL(SP)-1]) ? FL(t) : FL(f);
NEXT_OP;
OP(OP_JMPL)
@@ -1301,11 +1301,11 @@
NEXT_OP;
OP(OP_BRFL)
- ip += POP() == FL(FL_F) ? GET_INT32(ip) : 4;
+ ip += POP() == FL(f) ? GET_INT32(ip) : 4;
NEXT_OP;
OP(OP_BRTL)
- ip += POP() != FL(FL_F) ? GET_INT32(ip) : 4;
+ ip += POP() != FL(f) ? GET_INT32(ip) : 4;
NEXT_OP;
OP(OP_BRNEL)
@@ -1314,24 +1314,24 @@
NEXT_OP;
OP(OP_BRNNL)
- ip += POP() != FL(NIL) ? GET_INT32(ip) : 4;
+ ip += POP() != FL(Nil) ? GET_INT32(ip) : 4;
NEXT_OP;
OP(OP_BRN)
- ip += POP() == FL(NIL) ? GET_INT16(ip) : 2;
+ ip += POP() == FL(Nil) ? GET_INT16(ip) : 2;
NEXT_OP;
OP(OP_BRNL)
- ip += POP() == FL(NIL) ? GET_INT32(ip) : 4;
+ ip += POP() == FL(Nil) ? GET_INT32(ip) : 4;
NEXT_OP;
OP(OP_EQV)
if(FL(Stack)[FL(SP)-2] == FL(Stack)[FL(SP)-1])
- v = FL(FL_T);
+ v = FL(t);
else if(!leafp(FL(Stack)[FL(SP)-2]) || !leafp(FL(Stack)[FL(SP)-1]))
- v = FL(FL_F);
+ v = FL(f);
else
- v = compare_(FL(Stack)[FL(SP)-2], FL(Stack)[FL(SP)-1], 1) == 0 ? FL(FL_T) : FL(FL_F);
+ v = compare_(FL(Stack)[FL(SP)-2], FL(Stack)[FL(SP)-1], 1) == 0 ? FL(t) : FL(f);
FL(Stack)[FL(SP)-2] = v;
POPN(1);
NEXT_OP;
@@ -1338,9 +1338,9 @@
OP(OP_EQUAL)
if(FL(Stack)[FL(SP)-2] == FL(Stack)[FL(SP)-1])
- v = FL(FL_T);
+ v = FL(t);
else
- v = compare_(FL(Stack)[FL(SP)-2], FL(Stack)[FL(SP)-1], 1) == 0 ? FL(FL_T) : FL(FL_F);
+ v = compare_(FL(Stack)[FL(SP)-2], FL(Stack)[FL(SP)-1], 1) == 0 ? FL(t) : FL(f);
FL(Stack)[FL(SP)-2] = v;
POPN(1);
NEXT_OP;
@@ -1363,7 +1363,7 @@
POPN(n);
PUSH(v);
}else{
- PUSH(FL(NIL));
+ PUSH(FL(Nil));
}
NEXT_OP;
@@ -1492,10 +1492,10 @@
OP(OP_NUMEQ)
v = FL(Stack)[FL(SP)-2]; e = FL(Stack)[FL(SP)-1];
if(bothfixnums(v, e))
- v = v == e ? FL(FL_T) : FL(FL_F);
+ v = v == e ? FL(t) : FL(f);
else{
FL(Stack)[ipd] = (uintptr_t)ip;
- v = numeric_compare(v, e, 1, 0, 1) == 0 ? FL(FL_T) : FL(FL_F);
+ v = numeric_compare(v, e, 1, 0, 1) == 0 ? FL(t) : FL(f);
}
POPN(1);
FL(Stack)[FL(SP)-1] = v;
@@ -1549,7 +1549,7 @@
FL(Stack)[ipd] = (uintptr_t)ip;
s = tofixnum(FL(Stack)[FL(SP)-3]);
hi = tofixnum(FL(Stack)[FL(SP)-2]);
- v = FL(FL_UNSPECIFIED);
+ v = FL(unspecified);
FL(SP) += 2;
n = FL(SP);
for(; s <= hi; s++){
@@ -1563,7 +1563,7 @@
NEXT_OP;
OP(OP_LOADNIL)
- PUSH(FL(NIL));
+ PUSH(FL(Nil));
NEXT_OP;
OP(OP_LOADI8)
@@ -1677,7 +1677,7 @@
FL(Stack)[FL(SP)-3] = i+1;
FL(Stack)[FL(SP)-4] = FL(Stack)[FL(SP)-5];
FL(Stack)[FL(SP)-5] = FL(Stack)[FL(SP)-6];
- FL(Stack)[FL(SP)-6] = FL(NIL);
+ FL(Stack)[FL(SP)-6] = FL(Nil);
FL(curr_frame) = FL(SP);
}
ipd = FL(SP)-2;
@@ -1727,7 +1727,7 @@
i = GET_INT32(ip);
ip += 4;
v = captured ? vector_elt(FL(Stack)[bp], i) : FL(Stack)[bp+i];
- PUSH(v != UNBOUND ? FL(FL_T) : FL(FL_F));
+ PUSH(v != UNBOUND ? FL(t) : FL(f));
NEXT_OP;
OP(OP_KEYARGS)
@@ -1780,7 +1780,7 @@
static value_t
_stacktrace(uint32_t top)
{
- value_t lst = FL(NIL);
+ value_t lst = FL(Nil);
fl_gc_handle(&lst);
while(top > 0){
@@ -1801,7 +1801,7 @@
value_t si = FL(Stack)[bp+i];
// if there's an error evaluating argument defaults some slots
// might be left set to UNBOUND (issue #22)
- vector_elt(v, i+1) = si == UNBOUND ? FL(FL_UNSPECIFIED) : si;
+ vector_elt(v, i+1) = si == UNBOUND ? FL(unspecified) : si;
}
}
lst = fl_cons(v, lst);
@@ -1818,7 +1818,7 @@
USED(args);
argcount(nargs, 0);
gc(0);
- return FL(FL_T);
+ return FL(t);
}
BUILTIN("function", function)
@@ -1854,8 +1854,8 @@
value_t fv = tagptr(fn, TAG_FUNCTION);
fn->bcode = args[0];
fn->vals = args[1];
- fn->env = FL(NIL);
- fn->name = FL(LAMBDA);
+ fn->env = FL(Nil);
+ fn->name = FL(lambda);
if(nargs > 2){
if(issymbol(args[2])){
fn->name = args[2];
@@ -1919,10 +1919,10 @@
BUILTIN("append", append)
{
- value_t first = FL(NIL), lst, lastcons = FL(NIL);
+ value_t first = FL(Nil), lst, lastcons = FL(Nil);
int i;
if(nargs == 0)
- return FL(NIL);
+ return FL(Nil);
fl_gc_handle(&first);
fl_gc_handle(&lastcons);
for(i = 0; i < nargs; i++){
@@ -1929,12 +1929,12 @@
lst = args[i];
if(iscons(lst)){
lst = copy_list(lst);
- if(first == FL(NIL))
+ if(first == FL(Nil))
first = lst;
else
cdr_(lastcons) = lst;
lastcons = tagptr((((cons_t*)FL(curheap))-1), TAG_CONS);
- }else if(lst != FL(NIL)){
+ }else if(lst != FL(Nil)){
type_error("cons", lst);
}
}
@@ -1963,7 +1963,7 @@
if(__unlikely(nargs < 2))
lerrorf(FL(ArgError), "too few arguments");
if(!iscons(args[1]))
- return FL(NIL);
+ return FL(Nil);
value_t first, last, v;
int64_t argSP = args-FL(Stack);
assert(argSP >= 0 && argSP < FL(N_STACK));
@@ -1975,7 +1975,7 @@
v = _applyn(1);
PUSH(v);
v = mk_cons();
- car_(v) = POP(); cdr_(v) = FL(NIL);
+ car_(v) = POP(); cdr_(v) = FL(Nil);
last = first = v;
FL(Stack)[argSP+1] = cdr_(FL(Stack)[argSP+1]);
fl_gc_handle(&first);
@@ -1986,7 +1986,7 @@
v = _applyn(1);
PUSH(v);
v = mk_cons();
- car_(v) = POP(); cdr_(v) = FL(NIL);
+ car_(v) = POP(); cdr_(v) = FL(Nil);
cdr_(last) = v;
last = v;
FL(Stack)[argSP+1] = cdr_(FL(Stack)[argSP+1]);
@@ -2006,7 +2006,7 @@
POPN(nargs);
PUSH(v);
v = mk_cons();
- car_(v) = POP(); cdr_(v) = FL(NIL);
+ car_(v) = POP(); cdr_(v) = FL(Nil);
last = first = v;
fl_gc_handle(&first);
fl_gc_handle(&last);
@@ -2020,7 +2020,7 @@
POPN(nargs);
PUSH(v);
v = mk_cons();
- car_(v) = POP(); cdr_(v) = FL(NIL);
+ car_(v) = POP(); cdr_(v) = FL(Nil);
cdr_(last) = v;
last = v;
}
@@ -2035,7 +2035,7 @@
argcount(nargs, 1);
double s = nargs > 0 ? todouble(args[0]) : 0;
sleep_ms(s * 1000.0);
- return FL(FL_T);
+ return FL(t);
}
static const builtinspec_t builtin_fns[] = {
@@ -2066,18 +2066,18 @@
FL(N_STACK) = 262144;
FL(Stack) = LLT_ALLOC(FL(N_STACK)*sizeof(value_t));
- FL(FL_NIL) = FL(NIL) = builtin(OP_THE_EMPTY_LIST);
- FL(FL_T) = builtin(OP_BOOL_CONST_T);
- FL(FL_F) = builtin(OP_BOOL_CONST_F);
- FL(FL_EOF) = builtin(OP_EOF_OBJECT);
- FL(LAMBDA) = symbol("λ");
- FL(FUNCTION) = symbol("function");
- FL(QUOTE) = symbol("quote");
- FL(TRYCATCH) = symbol("trycatch");
- FL(BACKQUOTE) = symbol("quasiquote");
- FL(COMMA) = symbol("unquote");
- FL(COMMAAT) = symbol("unquote-splicing");
- FL(COMMADOT) = symbol("unquote-nsplicing");
+ FL(Nil) = builtin(OP_THE_EMPTY_LIST);
+ FL(t) = builtin(OP_BOOL_CONST_T);
+ FL(f) = builtin(OP_BOOL_CONST_F);
+ FL(eof) = builtin(OP_EOF_OBJECT);
+ FL(lambda) = symbol("λ");
+ FL(function) = symbol("function");
+ FL(quote) = symbol("quote");
+ FL(trycatch) = symbol("trycatch");
+ FL(backquote) = symbol("quasiquote");
+ FL(comma) = symbol("unquote");
+ FL(commaat) = symbol("unquote-splicing");
+ FL(commadot) = symbol("unquote-nsplicing");
FL(IOError) = symbol("io-error");
FL(ParseError) = symbol("parse-error");
FL(TypeError) = symbol("type-error");
@@ -2120,12 +2120,12 @@
FL(fsym) = symbol("f");
FL(Fsym) = symbol("F");
FL(builtins_table_sym) = symbol("*builtins*");
- set(FL(printprettysym) = symbol("*print-pretty*"), FL(FL_T));
- set(FL(printreadablysym) = symbol("*print-readably*"), FL(FL_T));
+ set(FL(printprettysym) = symbol("*print-pretty*"), FL(t));
+ set(FL(printreadablysym) = symbol("*print-readably*"), FL(t));
set(FL(printwidthsym) = symbol("*print-width*"), fixnum(FL(SCR_WIDTH)));
- set(FL(printlengthsym) = symbol("*print-length*"), FL(FL_F));
- set(FL(printlevelsym) = symbol("*print-level*"), FL(FL_F));
- FL(lasterror) = FL(NIL);
+ set(FL(printlengthsym) = symbol("*print-length*"), FL(f));
+ set(FL(printlevelsym) = symbol("*print-level*"), FL(f));
+ FL(lasterror) = FL(Nil);
for(i = 0; i < nelem(builtins); i++){
if(builtins[i].name)
setc(symbol(builtins[i].name), builtin(i));
--- a/flisp.h
+++ b/flisp.h
@@ -150,7 +150,7 @@
// assumes "nargs" is the argument count
#define FOR_ARGS(i, i0, arg, args) for(i=i0; i<nargs && ((arg=args[i]) || 1); i++)
#define N_BUILTINS ((int)N_OPCODES)
-#define FL_UNSPECIFIED FL_T
+#define unspecified t
#define PUSH(v) \
do{ \
@@ -348,9 +348,9 @@
uint32_t throwing_frame; // active frame when exception was thrown
value_t lasterror;
- value_t FL_NIL, FL_T, FL_F, FL_EOF, QUOTE;
- value_t NIL, LAMBDA, IF, TRYCATCH;
- value_t BACKQUOTE, COMMA, COMMAAT, COMMADOT, FUNCTION;
+ value_t Nil, t, f, eof, quote;
+ value_t lambda, trycatch;
+ value_t backquote, comma, commaat, commadot, function;
value_t printwidthsym, printreadablysym, printprettysym, printlengthsym;
value_t printlevelsym, builtins_table_sym;
--- a/flmain.c
+++ b/flmain.c
@@ -13,7 +13,7 @@
argv_list(int argc, char *argv[])
{
int i;
- value_t lst = FL(FL_NIL), temp;
+ value_t lst = FL(Nil), temp;
fl_gc_handle(&lst);
fl_gc_handle(&temp);
for(i = argc-1; i >= 0; i--){
--- a/iostream.c
+++ b/iostream.c
@@ -45,7 +45,7 @@
BUILTIN("iostream?", iostreamp)
{
argcount(nargs, 1);
- return isiostream(args[0]) ? FL(FL_T) : FL(FL_F);
+ return isiostream(args[0]) ? FL(t) : FL(f);
}
BUILTIN("eof-object", eof_object)
@@ -52,13 +52,13 @@
{
USED(args);
argcount(nargs, 0);
- return FL(FL_EOF);
+ return FL(eof);
}
BUILTIN("eof-object?", eof_objectp)
{
argcount(nargs, 1);
- return args[0] == FL(FL_EOF) ? FL(FL_T) : FL(FL_F);
+ return args[0] == FL(eof) ? FL(t) : FL(f);
}
ios_t *
@@ -123,7 +123,7 @@
value_t v = fl_read_sexpr(arg);
fl_free_gc_handles(1);
if(ios_eof(s))
- return FL(FL_EOF);
+ return FL(eof);
return v;
}
@@ -135,7 +135,7 @@
int res;
if((res = ios_getutf8(s, &r)) == IOS_EOF)
//lerrorf(FL(IOError), "end of file reached");
- return FL(FL_EOF);
+ return FL(eof);
if(res == 0)
lerrorf(FL(IOError), "invalid UTF-8 sequence");
return mk_rune(r);
@@ -148,9 +148,9 @@
ios_t *s = toiostream(args[0]);
int r = ios_wait(s, nargs > 1 ? todouble(args[1]) : -1);
if(r >= 0)
- return r ? FL(FL_T) : FL(FL_F);
+ return r ? FL(t) : FL(f);
if(r == IOS_EOF)
- return FL(FL_EOF);
+ return FL(eof);
lerrorf(FL(IOError), "i/o error");
}
@@ -171,7 +171,7 @@
off_t off = tooffset(args[1]);
off_t res = ios_skip(s, off);
if(res < 0)
- return FL(FL_F);
+ return FL(f);
return sizeof(res) == sizeof(int64_t) ? mk_int64(res) : mk_int32(res);
}
@@ -178,7 +178,7 @@
BUILTIN("io-flush", io_flush)
{
argcount(nargs, 1);
- return ios_flush(toiostream(args[0])) == 0 ? FL(FL_T) : FL(FL_F);
+ return ios_flush(toiostream(args[0])) == 0 ? FL(t) : FL(f);
}
BUILTIN("io-close", io_close)
@@ -185,7 +185,7 @@
{
argcount(nargs, 1);
ios_close(toiostream(args[0]));
- return FL(FL_T);
+ return FL(t);
}
BUILTIN("io-discardbuffer", io_discardbuffer)
@@ -192,13 +192,13 @@
{
argcount(nargs, 1);
ios_purge(toiostream(args[0]));
- return FL(FL_T);
+ return FL(t);
}
BUILTIN("io-eof?", io_eofp)
{
argcount(nargs, 1);
- return ios_eof(toiostream(args[0])) ? FL(FL_T) : FL(FL_F);
+ return ios_eof(toiostream(args[0])) ? FL(t) : FL(f);
}
BUILTIN("io-seek", io_seek)
@@ -208,8 +208,8 @@
size_t pos = toulong(args[1]);
off_t res = ios_seek(s, (off_t)pos);
if(res < 0)
- return FL(FL_F);
- return FL(FL_T);
+ return FL(f);
+ return FL(t);
}
BUILTIN("io-pos", io_pos)
@@ -218,7 +218,7 @@
ios_t *s = toiostream(args[0]);
off_t res = ios_pos(s);
if(res < 0)
- return FL(FL_F);
+ return FL(f);
return size_wrap((size_t)res);
}
@@ -257,7 +257,7 @@
size_t got = ios_read(s, data, n);
if(got < n)
//lerrorf(FL(IOError), "end of input reached");
- return FL(FL_EOF);
+ return FL(eof);
return cv;
}
@@ -309,7 +309,7 @@
data += offs;
}
hexdump(s, data, nb, offs);
- return FL(FL_T);
+ return FL(t);
}
static char
@@ -346,7 +346,7 @@
((uint8_t*)cv->data)[n] = 0;
}
if(n == 0 && ios_eof(src))
- return FL(FL_EOF);
+ return FL(eof);
return str;
}
@@ -384,7 +384,7 @@
}else{
uint8_t *b = ios_takebuf(st, &n); n--;
b[n] = '\0';
- str = cvalue_from_ref(FL(stringtype), b, n, FL(FL_NIL));
+ str = cvalue_from_ref(FL(stringtype), b, n, FL(Nil));
cv_autorelease(ptr(str));
}
return str;
@@ -411,7 +411,7 @@
FL(instrsym) = symbol("*input-stream*");
FL(outstrsym) = symbol("*output-stream*");
FL(iostreamtype) = define_opaque_type(FL(iostreamsym), sizeof(ios_t), &iostream_vtable, nil);
- setc(symbol("*stdout*"), cvalue_from_ref(FL(iostreamtype), ios_stdout, sizeof(ios_t), FL(FL_NIL)));
- setc(symbol("*stderr*"), cvalue_from_ref(FL(iostreamtype), ios_stderr, sizeof(ios_t), FL(FL_NIL)));
- setc(symbol("*stdin*" ), cvalue_from_ref(FL(iostreamtype), ios_stdin, sizeof(ios_t), FL(FL_NIL)));
+ setc(symbol("*stdout*"), cvalue_from_ref(FL(iostreamtype), ios_stdout, sizeof(ios_t), FL(Nil)));
+ setc(symbol("*stderr*"), cvalue_from_ref(FL(iostreamtype), ios_stderr, sizeof(ios_t), FL(Nil)));
+ setc(symbol("*stdin*" ), cvalue_from_ref(FL(iostreamtype), ios_stdin, sizeof(ios_t), FL(Nil)));
}
--- a/print.c
+++ b/print.c
@@ -173,8 +173,8 @@
return (cv_len((cvalue_t*)ptr(v)) < SMALL_STR_LEN);
return (
isfixnum(v) || isbuiltin(v) || iscprim(v) ||
- v == FL(FL_F) || v == FL(FL_T) ||
- v == FL(FL_NIL) || v == FL(FL_EOF)
+ v == FL(f) || v == FL(t) ||
+ v == FL(Nil) || v == FL(eof)
);
}
@@ -187,7 +187,7 @@
return 1;
if(iscons(v)){
if(tinyp(car_(v)) &&
- (tinyp(cdr_(v)) || (iscons(cdr_(v)) && tinyp(car_(cdr_(v))) && cdr_(cdr_(v)) == FL(NIL))))
+ (tinyp(cdr_(v)) || (iscons(cdr_(v)) && tinyp(car_(cdr_(v))) && cdr_(cdr_(v)) == FL(Nil))))
return 1;
return 0;
}
@@ -205,7 +205,7 @@
specialindent(value_t head)
{
// indent these forms 2 spaces, not lined up with the first argument
- if(head == FL(LAMBDA) || head == FL(TRYCATCH) || head == FL(definesym) ||
+ if(head == FL(lambda) || head == FL(trycatch) || head == FL(definesym) ||
head == FL(defmacrosym) || head == FL(forsym))
return 2;
return -1;
@@ -258,10 +258,10 @@
// indent before every subform of a special form, unless every
// subform is "small"
value_t c = car_(v);
- if(c == FL(LAMBDA) || c == FL(setqsym))
+ if(c == FL(lambda) || c == FL(setqsym))
return 0;
- if(c == FL(IF)) // TODO: others
- return !allsmallp(cdr_(v));
+ //if(c == FL(IF)) // TODO: others
+ // return !allsmallp(cdr_(v));
return 0;
}
@@ -280,13 +280,13 @@
{
value_t cd;
char *op;
- if(iscons(cdr_(v)) && cdr_(cdr_(v)) == FL(NIL) &&
+ if(iscons(cdr_(v)) && cdr_(cdr_(v)) == FL(Nil) &&
!ptrhash_has(&FL(printconses), (void*)cdr_(v)) &&
- (((car_(v) == FL(QUOTE)) && (op = "'")) ||
- ((car_(v) == FL(BACKQUOTE)) && (op = "`")) ||
- ((car_(v) == FL(COMMA)) && (op = ",")) ||
- ((car_(v) == FL(COMMAAT)) && (op = ",@")) ||
- ((car_(v) == FL(COMMADOT)) && (op = ",.")))){
+ (((car_(v) == FL(quote)) && (op = "'")) ||
+ ((car_(v) == FL(backquote)) && (op = "`")) ||
+ ((car_(v) == FL(comma)) && (op = ",")) ||
+ ((car_(v) == FL(commaat)) && (op = ",@")) ||
+ ((car_(v) == FL(commadot)) && (op = ",.")))){
// special prefix syntax
unmark_cons(v);
unmark_cons(cdr_(v));
@@ -306,7 +306,7 @@
int n_unindented = 1;
while(1){
cd = cdr_(v);
- if(FL(print_length) >= 0 && n >= FL(print_length) && cd != FL(NIL)){
+ if(FL(print_length) >= 0 && n >= FL(print_length) && cd != FL(Nil)){
outsn("...)", f, 4);
break;
}
@@ -314,7 +314,7 @@
unmark_cons(v);
fl_print_child(f, car_(v));
if(!iscons(cd) || ptrhash_has(&FL(printconses), (void*)cd)){
- if(cd != FL(NIL)){
+ if(cd != FL(Nil)){
outsn(" . ", f, 3);
fl_print_child(f, cd);
}
@@ -323,7 +323,7 @@
}
if(!FL(print_pretty) ||
- ((head == FL(LAMBDA)) && n == 0)){
+ ((head == FL(lambda)) && n == 0)){
// never break line before lambda-list
ind = 0;
}else{
@@ -337,7 +337,7 @@
(est != -1 && (FL(HPOS)+est > FL(SCR_WIDTH)-2)) ||
- ((head == FL(LAMBDA)) && !nextsmall) ||
+ ((head == FL(lambda)) && !nextsmall) ||
(n > 0 && always) ||
@@ -412,13 +412,13 @@
print_symbol_name(f, name);
break;
case TAG_FUNCTION:
- if(v == FL(FL_T))
+ if(v == FL(t))
outsn("#t", f, 2);
- else if(v == FL(FL_F))
+ else if(v == FL(f))
outsn("#f", f, 2);
- else if(v == FL(FL_NIL))
+ else if(v == FL(Nil))
outsn("()", f, 2);
- else if(v == FL(FL_EOF))
+ else if(v == FL(eof))
outsn("#<eof>", f, 6);
else if(isbuiltin(v)){
if(!FL(print_princ))
@@ -440,11 +440,11 @@
data[i] -= 48;
outc(' ', f);
fl_print_child(f, fn->vals);
- if(fn->env != FL(NIL)){
+ if(fn->env != FL(Nil)){
outc(' ', f);
fl_print_child(f, fn->env);
}
- if(fn->name != FL(LAMBDA)){
+ if(fn->name != FL(lambda)){
outc(' ', f);
fl_print_child(f, fn->name);
}
@@ -853,10 +853,10 @@
void
fl_print(ios_t *f, value_t v)
{
- FL(print_pretty) = symbol_value(FL(printprettysym)) != FL(FL_F);
+ FL(print_pretty) = symbol_value(FL(printprettysym)) != FL(f);
if(FL(print_pretty))
set_print_width();
- FL(print_princ) = symbol_value(FL(printreadablysym)) == FL(FL_F);
+ FL(print_princ) = symbol_value(FL(printreadablysym)) == FL(f);
value_t pl = symbol_value(FL(printlengthsym));
FL(print_length) = isfixnum(pl) ? numval(pl) : -1;
pl = symbol_value(FL(printlevelsym));
@@ -874,6 +874,6 @@
memset(FL(consflags), 0, 4*bitvector_nwords(FL(heapsize)/sizeof(cons_t)));
if((iscons(v) || isvector(v) || isfunction(v) || iscvalue(v)) &&
- !fl_isstring(v) && v != FL(FL_T) && v != FL(FL_F) && v != FL(FL_NIL))
+ !fl_isstring(v) && v != FL(t) && v != FL(f) && v != FL(Nil))
htable_reset(&FL(printconses), 32);
}
--- a/read.c
+++ b/read.c
@@ -85,7 +85,7 @@
return x;
}
-#define F value2c(ios_t*, FL(readstate)->source)
+#define RS value2c(ios_t*, FL(readstate)->source)
int
isnumtok_base(char *tok, value_t *pval, int base)
@@ -168,7 +168,7 @@
{
int ch;
char c;
- ios_t *f = F;
+ ios_t *f = RS;
do{
if(f->bpos < f->size){
@@ -215,8 +215,8 @@
while(1){
if(nc != 0){
if(nc != 1)
- ios_getc(F);
- ch = ios_peekc(F);
+ ios_getc(RS);
+ ch = ios_peekc(RS);
if(ch == IOS_EOF)
goto terminate;
c = (char)ch;
@@ -226,8 +226,8 @@
escaped = !escaped;
}else if(c == '\\'){
issym = 1;
- ios_getc(F);
- ch = ios_peekc(F);
+ ios_getc(RS);
+ ch = ios_peekc(RS);
if(ch == IOS_EOF)
goto terminate;
accumchar((char)ch, &i);
@@ -239,7 +239,7 @@
nc++;
}
if(nc == 0)
- ios_skip(F, -1);
+ ios_skip(RS, -1);
terminate:
buf[i++] = '\0';
return issym;
@@ -263,7 +263,7 @@
if(toktype != TOK_NONE)
return toktype;
c = nextchar();
- if(ios_eof(F))
+ if(ios_eof(RS))
return TOK_NONE;
if(c == '(')
toktype = TOK_OPEN;
@@ -284,7 +284,7 @@
else if(c == '"')
toktype = TOK_DOUBLEQUOTE;
else if(c == '#'){
- ch = ios_getc(F); c = (char)ch;
+ ch = ios_getc(RS); c = (char)ch;
if(ch == IOS_EOF)
lerrorf(FL(ParseError), "invalid read macro");
if(c == '.')
@@ -293,7 +293,7 @@
toktype = TOK_SHARPQUOTE;
else if(c == '\\'){
Rune cval;
- if(ios_getutf8(F, &cval) == IOS_EOF)
+ if(ios_getutf8(RS, &cval) == IOS_EOF)
lerrorf(FL(ParseError), "end of input in character constant");
if(cval == 'u' || cval == 'U' || cval == 'x'){
read_token('u', 0);
@@ -329,7 +329,7 @@
lerrorf(FL(ParseError), "unreadable object");
}else if(isdigit(c)){
read_token(c, 1);
- c = (char)ios_getc(F);
+ c = (char)ios_getc(RS);
if(c == '#')
toktype = TOK_BACKREF;
else if(c == '=')
@@ -343,7 +343,7 @@
}else if(c == '!'){
// #! single line comment for shbang script support
do{
- ch = ios_getc(F);
+ ch = ios_getc(RS);
}while(ch != IOS_EOF && (char)ch != '\n');
return peek();
}else if(c == '|'){
@@ -350,12 +350,12 @@
// multiline comment
int commentlevel = 1;
while(1){
- ch = ios_getc(F);
+ ch = ios_getc(RS);
hashpipe_gotc:
if(ch == IOS_EOF)
lerrorf(FL(ParseError), "eof within comment");
if((char)ch == '|'){
- ch = ios_getc(F);
+ ch = ios_getc(RS);
if((char)ch == '#'){
commentlevel--;
if(commentlevel == 0)
@@ -365,7 +365,7 @@
}
goto hashpipe_gotc;
}else if((char)ch == '#'){
- ch = ios_getc(F);
+ ch = ios_getc(RS);
if((char)ch == '|')
commentlevel++;
else
@@ -380,9 +380,9 @@
return peek();
}else if(c == ':'){
// gensym
- ch = ios_getc(F);
+ ch = ios_getc(RS);
if((char)ch == 'g')
- ch = ios_getc(F);
+ ch = ios_getc(RS);
read_token((char)ch, 0);
x = strtol(buf, &end, 10);
if(*end != '\0' || buf[0] == '\0')
@@ -408,7 +408,7 @@
}
}else if(c == ','){
toktype = TOK_COMMA;
- ch = ios_peekc(F);
+ ch = ios_peekc(RS);
if(ch == IOS_EOF)
return toktype;
if((char)ch == '@')
@@ -417,7 +417,7 @@
toktype = TOK_COMMADOT;
else
return toktype;
- ios_getc(F);
+ ios_getc(RS);
}else{
if(!read_token(c, 0)){
if(buf[0] == '.' && buf[1] == '\0')
@@ -463,7 +463,7 @@
if(label != UNBOUND)
ptrhash_put(&FL(readstate)->backrefs, (void*)label, (void*)v);
while(peek() != closer){
- if(ios_eof(F))
+ if(ios_eof(RS))
lerrorf(FL(ParseError), "unexpected end of input");
if(i >= vector_size(v)){
v = FL(Stack)[FL(SP)-1] = vector_grow(v);
@@ -503,7 +503,7 @@
}
buf = temp;
}
- c = ios_getc(F);
+ c = ios_getc(RS);
if(c == IOS_EOF){
LLT_FREE(buf);
lerrorf(FL(ParseError), "unexpected end of input in string");
@@ -511,7 +511,7 @@
if(c == '"')
break;
else if(c == '\\'){
- c = ios_getc(F);
+ c = ios_getc(RS);
if(c == IOS_EOF){
LLT_FREE(buf);
lerrorf(FL(ParseError), "end of input in escape sequence");
@@ -520,10 +520,10 @@
if(octal_digit(c)){
while(1){
eseq[j++] = c;
- c = ios_peekc(F);
+ c = ios_peekc(RS);
if(c == IOS_EOF || !octal_digit(c) || j >= 3)
break;
- ios_getc(F);
+ ios_getc(RS);
}
eseq[j] = '\0';
r = strtol(eseq, nil, 8);
@@ -531,11 +531,11 @@
buf[i++] = (char)r;
}else if((c == 'x' && (ndig = 2)) || (c == 'u' && (ndig = 4)) || (c == 'U' && (ndig = 8))){
while(1){
- c = ios_peekc(F);
+ c = ios_peekc(RS);
if(c == IOS_EOF || !hex_digit(c) || j >= ndig)
break;
eseq[j++] = c;
- ios_getc(F);
+ ios_getc(RS);
}
eseq[j] = '\0';
if(j)
@@ -577,13 +577,13 @@
value_t c, *pc;
uint32_t t;
- PUSH(FL(NIL));
+ PUSH(FL(Nil));
pc = &FL(Stack)[FL(SP)-1]; // to keep track of current cons cell
t = peek();
while(t != closer){
- if(ios_eof(F))
+ if(ios_eof(RS))
lerrorf(FL(ParseError), "unexpected end of input");
- c = mk_cons(); car_(c) = cdr_(c) = FL(NIL);
+ c = mk_cons(); car_(c) = cdr_(c) = FL(Nil);
if(iscons(*pc))
cdr_(*pc) = c;
else{
@@ -601,7 +601,7 @@
c = do_read_sexpr(UNBOUND);
cdr_(*pc) = c;
t = peek();
- if(ios_eof(F))
+ if(ios_eof(RS))
lerrorf(FL(ParseError), "unexpected end of input");
if(t != closer){
take();
@@ -642,20 +642,20 @@
case TOK_NUM:
return tokval;
case TOK_COMMA:
- head = &FL(COMMA); goto listwith;
+ head = &FL(comma); goto listwith;
case TOK_COMMAAT:
- head = &FL(COMMAAT); goto listwith;
+ head = &FL(commaat); goto listwith;
case TOK_COMMADOT:
- head = &FL(COMMADOT); goto listwith;
+ head = &FL(commadot); goto listwith;
case TOK_BQ:
- head = &FL(BACKQUOTE); goto listwith;
+ head = &FL(backquote); goto listwith;
case TOK_QUOTE:
- head = &FL(QUOTE);
+ head = &FL(quote);
listwith:
v = cons_reserve(2);
car_(v) = *head;
cdr_(v) = tagptr(((cons_t*)ptr(v))+1, TAG_CONS);
- car_(cdr_(v)) = cdr_(cdr_(v)) = FL(NIL);
+ car_(cdr_(v)) = cdr_(cdr_(v)) = FL(Nil);
PUSH(v);
if(label != UNBOUND)
ptrhash_put(&FL(readstate)->backrefs, (void*)label, (void*)v);
@@ -666,23 +666,23 @@
// femtoLisp doesn't need symbol-function, so #' does nothing
return do_read_sexpr(label);
case TOK_OPEN:
- PUSH(FL(NIL));
+ PUSH(FL(Nil));
read_list(&FL(Stack)[FL(SP)-1], label, TOK_CLOSE);
return POP();
case TOK_OPENB:
- PUSH(FL(NIL));
+ PUSH(FL(Nil));
read_list(&FL(Stack)[FL(SP)-1], label, TOK_CLOSEB);
return POP();
case TOK_OPENC:
- PUSH(FL(NIL));
+ PUSH(FL(Nil));
read_list(&FL(Stack)[FL(SP)-1], label, TOK_CLOSEC);
return POP();
case TOK_SHARPSYM:
sym = tokval;
if(sym == FL(tsym) || sym == FL(Tsym))
- return FL(FL_T);
+ return FL(t);
if(sym == FL(fsym) || sym == FL(Fsym))
- return FL(FL_F);
+ return FL(f);
// constructor notation
c = nextchar();
if(c != '('){
@@ -689,13 +689,13 @@
take();
lerrorf(FL(ParseError), "expected argument list for %s", symbol_name(tokval));
}
- PUSH(FL(NIL));
+ PUSH(FL(Nil));
read_list(&FL(Stack)[FL(SP)-1], UNBOUND, TOK_CLOSE);
if(sym == FL(vu8sym)){
sym = FL(arraysym);
FL(Stack)[FL(SP)-1] = fl_cons(FL(uint8sym), FL(Stack)[FL(SP)-1]);
}else if(sym == FL(fnsym)){
- sym = FL(FUNCTION);
+ sym = FL(function);
}
v = symbol_value(sym);
if(v == UNBOUND)
@@ -739,7 +739,7 @@
case TOK_DOUBLEQUOTE:
return read_string();
}
- return FL(FL_UNSPECIFIED);
+ return FL(unspecified);
}
value_t
--- a/sixel.c
+++ b/sixel.c
@@ -32,7 +32,7 @@
BUILTIN("sixel-ouput?", fsixel_outputp)
{
argcount(nargs, 1);
- return issixeloutput(args[0]) ? FL(FL_T) : FL(FL_F);
+ return issixeloutput(args[0]) ? FL(t) : FL(f);
}
static int
@@ -87,7 +87,7 @@
lerrorf(FL(ArgError), "invalid scale factor: %dx%d", scalex, scaley);
f->scalex = scalex;
f->scaley = scaley;
- return FL(FL_T);
+ return FL(t);
}
// :: sixel-output -> palette -> [paltype ->] ...
@@ -161,7 +161,7 @@
}
sixel_dither_set_palette(f->dither, out);
- return FL(FL_T);
+ return FL(t);
}
// :: sixel-output -> iostream -> pixels -> width -> height -> ...
@@ -212,7 +212,7 @@
r = sixel_encode(pix, w, h, 0, f->dither, f->out);
if(SIXEL_FAILED(r))
lerrorf(FL(IOError), "could not encode image");
- return FL(FL_T);
+ return FL(t);
}
static void
--- a/string.c
+++ b/string.c
@@ -13,7 +13,7 @@
BUILTIN("string?", stringp)
{
argcount(nargs, 1);
- return fl_isstring(args[0]) ? FL(FL_T) : FL(FL_F);
+ return fl_isstring(args[0]) ? FL(t) : FL(f);
}
BUILTIN("string-length", string_length)
@@ -48,7 +48,7 @@
cprim_t *cp = ptr(args[0]);
if(cp_class(cp) == FL(runetype)){
int w = wcwidth(*(Rune*)cp_data(cp));
- return w < 0 ? FL(FL_F) : fixnum(w);
+ return w < 0 ? FL(f) : fixnum(w);
}
}
return size_wrap(u8_strwidth(tostring(args[0])));
@@ -89,7 +89,7 @@
{
int term = 0;
if(nargs == 2)
- term = args[1] != FL(FL_F);
+ term = args[1] != FL(f);
else
argcount(nargs, 1);
if(!fl_isstring(args[0]))
@@ -123,8 +123,8 @@
int i;
value_t oldpr = symbol_value(FL(printreadablysym));
value_t oldpp = symbol_value(FL(printprettysym));
- set(FL(printreadablysym), FL(FL_F));
- set(FL(printprettysym), FL(FL_F));
+ set(FL(printreadablysym), FL(f));
+ set(FL(printprettysym), FL(f));
FOR_ARGS(i, 0, arg, args){
USED(arg);
fl_print(s, args[i]);
@@ -144,7 +144,7 @@
size_t len = cv_len(ptr(args[0]));
size_t dlen = cv_len(ptr(args[1]));
size_t ssz, tokend, tokstart, i = 0;
- value_t first = FL(FL_NIL), c = FL(FL_NIL), last;
+ value_t first = FL(Nil), c = FL(Nil), last;
size_t junk;
fl_gc_handle(&first);
fl_gc_handle(&last);
@@ -156,7 +156,7 @@
tokend = i;
ssz = tokend - tokstart;
last = c; // save previous cons cell
- c = fl_cons(cvalue_string(ssz), FL(FL_NIL));
+ c = fl_cons(cvalue_string(ssz), FL(Nil));
// we've done allocation; reload movable pointers
s = cv_data(ptr(args[0]));
@@ -166,7 +166,7 @@
memmove(cv_data(ptr(car_(c))), &s[tokstart], ssz);
// link new cell
- if(last == FL(FL_NIL))
+ if(last == FL(Nil))
first = c; // first time, save first cons
else
((cons_t*)ptr(last))->cdr = c;
@@ -253,7 +253,7 @@
cprim_t *cp = ptr(args[0]);
if(!iscprim(args[0]) || cp_class(cp) != FL(runetype))
type_error("rune", args[0]);
- return isalpharune(*(Rune*)cp_data(cp)) ? FL(FL_T) : FL(FL_F);
+ return isalpharune(*(Rune*)cp_data(cp)) ? FL(t) : FL(f);
}
BUILTIN("char-lower-case?", char_lower_casep)
@@ -262,7 +262,7 @@
cprim_t *cp = ptr(args[0]);
if(!iscprim(args[0]) || cp_class(cp) != FL(runetype))
type_error("rune", args[0]);
- return islowerrune(*(Rune*)cp_data(cp)) ? FL(FL_T) : FL(FL_F);
+ return islowerrune(*(Rune*)cp_data(cp)) ? FL(t) : FL(f);
}
BUILTIN("char-upper-case?", char_upper_casep)
@@ -271,7 +271,7 @@
cprim_t *cp = ptr(args[0]);
if(!iscprim(args[0]) || cp_class(cp) != FL(runetype))
type_error("rune", args[0]);
- return isupperrune(*(Rune*)cp_data(cp)) ? FL(FL_T) : FL(FL_F);
+ return isupperrune(*(Rune*)cp_data(cp)) ? FL(t) : FL(f);
}
BUILTIN("char-title-case?", char_title_casep)
@@ -280,7 +280,7 @@
cprim_t *cp = ptr(args[0]);
if(!iscprim(args[0]) || cp_class(cp) != FL(runetype))
type_error("rune", args[0]);
- return istitlerune(*(Rune*)cp_data(cp)) ? FL(FL_T) : FL(FL_F);
+ return istitlerune(*(Rune*)cp_data(cp)) ? FL(t) : FL(f);
}
BUILTIN("char-numeric?", char_numericp)
@@ -289,7 +289,7 @@
cprim_t *cp = ptr(args[0]);
if(!iscprim(args[0]) || cp_class(cp) != FL(runetype))
type_error("rune", args[0]);
- return isdigitrune(*(Rune*)cp_data(cp)) ? FL(FL_T) : FL(FL_F);
+ return isdigitrune(*(Rune*)cp_data(cp)) ? FL(t) : FL(f);
}
BUILTIN("char-whitespace?", char_whitespacep)
@@ -298,7 +298,7 @@
cprim_t *cp = ptr(args[0]);
if(!iscprim(args[0]) || cp_class(cp) != FL(runetype))
type_error("rune", args[0]);
- return isspacerune(*(Rune*)cp_data(cp)) ? FL(FL_T) : FL(FL_F);
+ return isspacerune(*(Rune*)cp_data(cp)) ? FL(t) : FL(f);
}
BUILTIN("string-find", string_find)
@@ -335,7 +335,7 @@
type_error("string", args[1]);
}
if(needlesz > len-start)
- return FL(FL_F);
+ return FL(f);
if(needlesz == 0)
return size_wrap(start);
size_t i;
@@ -343,7 +343,7 @@
if(s[i] == needle[0] && memcmp(&s[i+1], needle+1, needlesz-1) == 0)
return size_wrap(i);
}
- return FL(FL_F);
+ return FL(f);
}
static unsigned long
@@ -392,7 +392,7 @@
if(nargs == 2)
radix = get_radix_arg(args[1]);
if(!isnumtok_base(str, &n, (int)radix))
- return FL(FL_F);
+ return FL(f);
return n;
}
@@ -401,5 +401,5 @@
argcount(nargs, 1);
char *s = tostring(args[0]);
size_t len = cv_len((cvalue_t*)ptr(args[0]));
- return u8_isvalid(s, len) ? FL(FL_T) : FL(FL_F);
+ return u8_isvalid(s, len) ? FL(t) : FL(f);
}
--- a/table.c
+++ b/table.c
@@ -76,7 +76,7 @@
BUILTIN("table?", tablep)
{
argcount(nargs, 1);
- return ishashtable(args[0]) ? FL(FL_T) : FL(FL_F);
+ return ishashtable(args[0]) ? FL(t) : FL(f);
}
static htable_t *
@@ -101,7 +101,7 @@
htable_t *h = (htable_t*)cv_data((cvalue_t*)ptr(nt));
htable_new(h, cnt/2);
int i;
- value_t k = FL(FL_NIL), arg;
+ value_t k = FL(Nil), arg;
FOR_ARGS(i, 0, arg, args){
if(i & 1)
equalhash_put(h, (void*)k, (void*)arg);
@@ -158,7 +158,7 @@
{
argcount(nargs, 2);
htable_t *h = totable(args[0]);
- return equalhash_has(h, (void*)args[1]) ? FL(FL_T) : FL(FL_F);
+ return equalhash_has(h, (void*)args[1]) ? FL(t) : FL(f);
}
// (del! table key)
--- a/terminal_posix.c
+++ b/terminal_posix.c
@@ -55,7 +55,7 @@
{
USED(args);
argcount(nargs, 0);
- return termsetraw(true, cursorvisible) == 0 ? FL(FL_T) : FL(FL_F);
+ return termsetraw(true, cursorvisible) == 0 ? FL(t) : FL(f);
}
BUILTIN("terminal-leave-raw-mode", terminal_leave_raw_mode)
@@ -62,7 +62,7 @@
{
USED(args);
argcount(nargs, 0);
- return termsetraw(false, cursorvisible) == 0 ? FL(FL_T) : FL(FL_F);
+ return termsetraw(false, cursorvisible) == 0 ? FL(t) : FL(f);
}
BUILTIN("terminal-show-cursor", terminal_show_cursor)
@@ -69,7 +69,7 @@
{
USED(args);
argcount(nargs, 0);
- return termsetraw(inraw, true) == 0 ? FL(FL_T) : FL(FL_F);
+ return termsetraw(inraw, true) == 0 ? FL(t) : FL(f);
}
BUILTIN("terminal-hide-cursor", terminal_hide_cursor)
@@ -76,7 +76,7 @@
{
USED(args);
argcount(nargs, 0);
- return termsetraw(inraw, false) == 0 ? FL(FL_T) : FL(FL_F);
+ return termsetraw(inraw, false) == 0 ? FL(t) : FL(f);
}
BUILTIN("terminal-get-size", terminal_get_size)
@@ -85,11 +85,11 @@
argcount(nargs, 0);
struct winsize s;
if(ioctl(STDIN_FILENO, TIOCGWINSZ, &s) < 0)
- return FL(FL_F);
+ return FL(f);
value_t v = mk_cons(), tex, pix;
car_(v) = tex = mk_cons();
car_(tex) = fixnum(s.ws_col);
- cdr_(tex) = mk_cons(); car_(cdr_(tex)) = fixnum(s.ws_row); cdr_(cdr_(tex)) = FL(NIL);
+ cdr_(tex) = mk_cons(); car_(cdr_(tex)) = fixnum(s.ws_row); cdr_(cdr_(tex)) = FL(Nil);
int x = s.ws_xpixel, y = s.ws_ypixel;
bool wasraw = inraw;
if((x == 0 || y == 0) && isatty(STDOUT_FILENO) && termsetraw(true, cursorvisible) == 0){
@@ -124,9 +124,9 @@
if(!wasraw)
termsetraw(false, cursorvisible);
}
- cdr_(v) = pix = mk_cons(); cdr_(pix) = FL(NIL);
+ cdr_(v) = pix = mk_cons(); cdr_(pix) = FL(Nil);
car_(pix) = mk_cons(); pix = car_(pix);
car_(pix) = fixnum(x);
- cdr_(pix) = mk_cons(); car_(cdr_(pix)) = fixnum(y); cdr_(cdr_(pix)) = FL(NIL);
+ cdr_(pix) = mk_cons(); car_(cdr_(pix)) = fixnum(y); cdr_(cdr_(pix)) = FL(Nil);
return v;
}