shithub: femtolisp

Download patch

ref: 22ae0e366f8678ac2df9104ba37c2e2ab9c0190d
parent: 6a78340ee7a0dc82389210e180a0767b5a449264
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Tue Nov 26 23:25:24 EST 2024

built-in symbols aren't constants anymore

--- a/README.md
+++ b/README.md
@@ -21,6 +21,7 @@
  * "boot" image is built into the executable
  * vm opcode definitions and tables are generated from a single file
  * fixed bootstrap (makes it work properly when opcodes change)
+ * built-in symbols aren't constants and can be redefined
 
 ## Building
 
--- a/cvalues.c
+++ b/cvalues.c
@@ -1456,10 +1456,10 @@
 	FL(cfunctionsym) = symbol("c-function", false);
 
 	FL(stringtypesym) = symbol("*string-type*", false);
-	setc(FL(stringtypesym), fl_list2(FL(arraysym), FL(bytesym)));
+	set(FL(stringtypesym), fl_list2(FL(arraysym), FL(bytesym)));
 
 	FL(runestringtypesym) = symbol("*runestring-type*", false);
-	setc(FL(runestringtypesym), fl_list2(FL(arraysym), FL(runesym)));
+	set(FL(runestringtypesym), fl_list2(FL(arraysym), FL(runesym)));
 
 	mk_primtype(int8, int8_t);
 	mk_primtype(uint8, uint8_t);
@@ -1483,5 +1483,5 @@
 	FL(runestringtype) = get_type(symbol_value(FL(runestringtypesym)));
 
 	FL(emptystringsym) = symbol("*empty-string*", false);
-	setc(FL(emptystringsym), cvalue_static_cstring(""));
+	set(FL(emptystringsym), cvalue_static_cstring(""));
 }
--- a/flisp.c
+++ b/flisp.c
@@ -2203,11 +2203,11 @@
 	FL(lasterror) = FL(Nil);
 	for(i = 0; i < nelem(builtins); i++){
 		if(builtins[i].name)
-			setc(symbol(builtins[i].name, false), builtin(i));
+			set(symbol(builtins[i].name, false), builtin(i));
 	}
-	setc(symbol("eq", false), builtin(OP_EQ));
-	setc(symbol("procedure?", false), builtin(OP_FUNCTIONP));
-	setc(symbol("top-level-bound?", false), builtin(OP_BOUNDP));
+	set(symbol("eq", false), builtin(OP_EQ));
+	set(symbol("procedure?", false), builtin(OP_FUNCTIONP));
+	set(symbol("top-level-bound?", false), builtin(OP_BOUNDP));
 
 	set(symbol("*os-name*", false), symbol(__os_name__, false));
 
@@ -2219,7 +2219,7 @@
 	FL(memory_exception_value) = fl_list2(FL(MemoryError), cvalue_static_cstring("out of memory"));
 	const builtinspec_t *b;
 	for(i = 0, b = builtin_fns; i < nelem(builtin_fns); i++, b++)
-		setc(symbol(b->name, false), cbuiltin(b->name, b->fptr));
+		set(symbol(b->name, false), cbuiltin(b->name, b->fptr));
 
 	table_init();
 	iostream_init();
--- a/iostream.c
+++ b/iostream.c
@@ -421,7 +421,7 @@
 	FL(instrsym) = symbol("*input-stream*", false);
 	FL(outstrsym) = symbol("*output-stream*", false);
 	FL(iostreamtype) = define_opaque_type(FL(iostreamsym), sizeof(ios_t), &iostream_vtable, nil);
-	setc(symbol("*stdout*", false), cvalue_from_ref(FL(iostreamtype), ios_stdout, sizeof(ios_t), FL(Nil)));
-	setc(symbol("*stderr*", false), cvalue_from_ref(FL(iostreamtype), ios_stderr, sizeof(ios_t), FL(Nil)));
-	setc(symbol("*stdin*", false), cvalue_from_ref(FL(iostreamtype), ios_stdin, sizeof(ios_t), FL(Nil)));
+	set(symbol("*stdout*", false), cvalue_from_ref(FL(iostreamtype), ios_stdout, sizeof(ios_t), FL(Nil)));
+	set(symbol("*stderr*", false), cvalue_from_ref(FL(iostreamtype), ios_stderr, sizeof(ios_t), FL(Nil)));
+	set(symbol("*stdin*", false), cvalue_from_ref(FL(iostreamtype), ios_stdin, sizeof(ios_t), FL(Nil)));
 }