commit feb4eadbc39cc4c163557aa1e7e9ee3459adfb43
parent d03fe89a3646355b160a47709f35e20a60a80700
Author: Ed van Bruggen <edvb@uw.edu>
Date: Wed, 17 Jul 2019 06:09:47 -0700
Option to return undefined symbol instead of error
Compiler flag in config.mk, disabled by default. Useful for math work,
behaves similar to mathematica.
Diffstat:
3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/config.mk b/config.mk
@@ -17,5 +17,11 @@ LDFLAGS = -Wl,-rpath=$(DESTDIR)$(PREFIX)/lib/tisp $(LIBS)
# turn off debug mode by default
DEBUG ?= 0
+# self evaluate symbols if they are not defined, instead of throwing error
+# CFLAGS += -DTSP_SYM_RETURN
+
+# do not load tibs statically, use load procedure instead
+# CFLAGS += -DTIB_DYNAMIC
+
# compiler and linker
CC = cc
diff --git a/main.c b/main.c
@@ -6,7 +6,7 @@
#include <string.h>
#include "tisp.h"
-#if !defined(TIB_DYNAMIC)
+#ifndef TIB_DYNAMIC
# include "tibs/math.h"
# include "tibs/io.h"
#endif
@@ -26,7 +26,7 @@ main(int argc, char *argv[])
}
Env env = tisp_env_init(64);
-#if !defined(TIB_DYNAMIC)
+#ifndef TIB_DYNAMIC
tib_env_math(env);
tib_env_io(env);
#endif
diff --git a/tisp.c b/tisp.c
@@ -703,7 +703,11 @@ tisp_eval(Env env, Val v)
switch (v->t) {
case SYMBOL:
if (!(f = hash_get(env->h, v->v.s)))
+#ifdef TSP_SYM_RETURN
+ return v;
+#else
tsp_warnf("could not find symbol %s", v->v.s);
+#endif
return f;
case PAIR:
if (!(f = tisp_eval(env, car(v))))