Hello, Dan!
Your book is great, thank you so much!
I've just finished Chapter 15 "Standard Library" and have a question.
There is a bonus mark: "Incorporate your standard library directly into the language. Make it load at start-up."
I implemented, but I don't like the way I did it.
The first try was to implement a function like load_std(lenv* e, char* string), where to pass a string representation of stdlib item. But with many items the code looks ugly.
The next idea was to create stdlib directory with *.lispy modules and load each one via load_stdlib(lenv* e, char* content). But they are loaded at runtime, not at compile-time, it's useless for users.
I found the way to include stdlib using the macro:
Hello, Dan! Your book is great, thank you so much!
I've just finished Chapter 15 "Standard Library" and have a question. There is a bonus mark: "Incorporate your standard library directly into the language. Make it load at start-up." I implemented, but I don't like the way I did it.
The first try was to implement a function like
load_std(lenv* e, char* string)
, where to pass a string representation of stdlib item. But with many items the code looks ugly.The next idea was to create
stdlib
directory with*.lispy
modules and load each one viaload_stdlib(lenv* e, char* content)
. But they are loaded at runtime, not at compile-time, it's useless for users.I found the way to include stdlib using the macro:
But I don't like this method because you need to wrap your lispy module with
R"( <lispy code> )"
.Is there a way to load lispy stdlib at compile-time and keep *.lispy modules clean?