According to some parts of ECL manual, necessary part of the library (that has been compiled by lisp) initialisation in C program is performing its initialisation as:
ecl_init_module(NULL, init_func_for_library);
In all examples provided first parameter is NULL.
What other values can it take and to what end? Certainly the parameter itself should have some meaning.
NB. In other parts of the manual, for performing initialisation, it is recommended to use read_VV instead. What does that do?
Inspecting the source code, we can see that NULL is bound to a variable named block
; when it is NULL
, a default, empty codeblock
is used instead:
cl_object
ecl_init_module(cl_object block, void (*entry_point)(cl_object))
{
...
if (block == NULL)
block = ecl_make_codeblock();
...
}
Code blocks look like some sort of context/environment structures:
cl_object
ecl_make_codeblock()
{
cl_object block = ecl_alloc(t_codeblock);
block = ecl_alloc_object(t_codeblock);
block->cblock.self_destruct = 0;
block->cblock.locked = 0;
block->cblock.handle = NULL;
block->cblock.data = NULL;
block->cblock.data_size = 0;
block->cblock.temp_data = NULL;
block->cblock.temp_data_size = 0;
block->cblock.data_text = NULL;
block->cblock.next = ECL_NIL;
block->cblock.name = ECL_NIL;
block->cblock.links = ECL_NIL;
block->cblock.cfuns_size = 0;
block->cblock.cfuns = NULL;
block->cblock.source = ECL_NIL;
block->cblock.error = ECL_NIL;
block->cblock.refs = ecl_make_fixnum(0);
si_set_finalizer(block, ECL_T);
return block;
}
I guess in most cases, passing NULL
is sufficient. Presumably you could call ecl_init_module
with an existing code block to share to some state with another module; without a better understanding of how the interpreter works, this is however risky.