commit c3f5fe806b26969f1e80439efa645205a5f7ebc3
parent 29bc2a4b0a2e83bba5a849edf2fda233a61de1e0
Author: Ed van Bruggen <edvb@uw.edu>
Date: Wed, 21 Mar 2018 23:35:58 -0700
Remove boolean type
Treat nil as false and self evaluating symbol t as true
Diffstat:
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/tisp.c b/tisp.c
@@ -29,8 +29,6 @@ typedef struct Str {
char *d;
} *Str;
-typedef enum { false, true } bool;
-
typedef enum {
ERROR_OK,
ERROR_SYNTAX
@@ -68,7 +66,6 @@ typedef struct {
typedef enum {
NIL,
- BOOLEAN,
INTEGER,
RATIONAL,
STRING,
@@ -244,7 +241,6 @@ Val FN_NAME(TYPE TYPE_NAME) { \
return ret; \
}
-MK_TYPE(bool, i, BOOLEAN, mk_bool)
MK_TYPE(int, i, INTEGER, mk_int)
MK_TYPE(char *, s, STRING, mk_str)
MK_TYPE(char *, s, SYMBOL, mk_sym)
@@ -332,8 +328,6 @@ Val
read_val(Str str)
{
skip_spaces(str);
- if (*str->d == '#') /* TODO check 2nd char */
- return mk_bool(*(++str->d) == 't' ? true : false);
if (isdigit(*str->d)) /* TODO negitive numbers */
return read_int(str);
if (*str->d == '"') /* TODO fix */
@@ -411,7 +405,6 @@ tisp_eval(Hash env, Val v)
Val f, args;
switch (v->t) {
case NIL:
- case BOOLEAN:
case INTEGER:
case RATIONAL:
case STRING:
@@ -445,9 +438,6 @@ tisp_print(Val v)
case NIL:
printf("()");
break;
- case BOOLEAN:
- printf(v->v.i ? "#t" : "#f");
- break;
case INTEGER:
printf("%d", v->v.i);
break;
@@ -503,6 +493,7 @@ init_env(void)
{
Hash h = hash_new(64);
hash_add(h, "+", mk_prim(add));
+ hash_add(h, "t", mk_sym("t"));
return h;
}