While you’re at it, I just thought of another modification code-wise that might be helpful to people who want to mod uLisp (which is like, half of its users from looking at this forum):
Instead of doing four separate sections in the source for the functions, the symbol strings, and the docstrings like this:
// ----- functions section ---- //
object* fn_foo(object* args, object* env) {
// ...
}
object* fn_bar(object* args, object* env) {
// ...
}
// ----- strings section ---- //
const char string_foo[] = "foo";
const char string_bar[] = "bar";
// ----- docstrings section ---- //
const char doc_foo[] = "Doc for foo";
const char doc_bar[] = "Doc for bar";
// ----- table section ---- //
const tbl_entry_t lookup_table[] = {
{ string_foo, fn_foo, 0123, doc_bar },
{ string_bar, fn_bar, 0156, doc_bar },
};
you could put the tbl_entry_t entries and strings and stuff interleaved next to the functions, which would make the number of sections that someone would have to scroll back and forth to only two, down from the current four:
// ----- functions section ---- //
object* fn_foo(object* args, object* env) {
// ...
}
const char string_foo[] = "foo";
const char doc_foo[] = "Doc for foo";
tbl_entry_t tb_foo = { string_foo, fn_foo, 0123, doc_foo };
object* fn_bar(object* args, object* env) {
// ...
}
const char string_bar[] = "bar";
const char doc_bar[] = "Doc for bar";
tbl_entry_t tb_bar = { string_bar, fn_bar, 0156, doc_bar };
// ----- table section ---- //
const tbl_entry_t lookup_table[] = {
tb_foo,
tb_bar,
};
A quick test showed that doing this doesn’t add any more bytes to the executable size.
I would have taken it one step further and inlined everything including the function itself by using a C++ lambda function, but strangely this added about 200 bytes to the executable size. Not sure why.