Why is the function compose
defined in the interpreter csi
and not in the compiler csc
? I know I can easily define it by myself, but I was just wondering why there is such a difference.
The compose
procedure is from the unit data-structures
(see the manual or API docs). You can load it by typing (use data-structures)
.
As to why it's available in csi
and not in csc
by default is a bit of a hairy implementation detail; the csi
interpreter simply needs to load a few modules itself in order to provide an interpreter environment. Due to the way it's implemented, everything that's loaded by csi
also becomes available at the top-level. In CHICKEN 5, this situation has improved quite a bit and the interpreter starts with a clean top-level environment.
So what this means in practice is that you should always explicitly (use)
all modules that your program needs, to ensure that it works in compiled mode as well as interpreted mode. Instead of putting your program at the top-level environment, you can also wrap your entire program inside a module. Modules always have a completely clean environment, so there will be no difference when you compile it versus when you interpret it.