A bytecodes object is a lisp object with a piece of code that can be
interpreted. The objects of type t_bytecode
are implicitly constructed
by a call to eval
, but can also be explicitly constructed with the
make_lambda
function.
Function: cl_objectcl_safe_eval
(cl_objectform
, cl_objectenv
, cl_objecterr_value
Function: cl_objectcl_eval
(cl_objectform
)
cl_safe_eval
evaluatesform
in the lexical environmentenv
, which can benil
. Before evaluating it, the expressionform
must be bytecompiled.cl_eval
is the equivalent ofcl_safe_eval
but without environment and witherr_value
set tonil
. It exists only for compatibility with previous versions.cl_object form = c_string_to_object("(print 1)"); cl_safe_eval(form,Cnil); cl_safe_eval(form, Cnil);
Function: cl_objectsi_make_lambda
(cl_objectname
, cl_objectdef
)Builds an interpreted lisp function with name given by the symbol
name
and body given bydef
. For instance, we would achieve the equivalent of(funcall #'(lambda (x y) (block foo (+ x y))) 1 2)with the following code
cl_object def = c_string_to_object("((x y) (+ x y))"); cl_object name = _intern("foo") cl_object fun = si_make_lambda(name, def); return funcall(fun, MAKE_FIXNUM(1), MAKE_FIXNUM(2));Notice that
si_safe_lambda
performs a bytecodes compilation of the definition and thus it may signal some errors. Such errors are not handled by the routine itself you might consider usingcl_safe_eval
orcl_eval
instead:cl_object def = c_string_to_object("#'(lambda-block foo (x y) (+ x y))"); cl_object fun = cl_eval(def); return funcall(fun, MAKE_FIXNUM(1), MAKE_FIXNUM(2));