Commit 94e4e9bf authored by Daniel Kochmański's avatar Daniel Kochmański

examples: add more C code to embed example

Including printing the result and funcalling lambda with arguments.
parent 612eeb5e
(defun hello-lisp () (format t "hello-lisp!~%")) (defun hello-lisp ()
\ No newline at end of file (format t "hello-lisp!~%")
:foo)
...@@ -12,7 +12,16 @@ int main (int argc, char **argv) { ...@@ -12,7 +12,16 @@ int main (int argc, char **argv) {
extern void init_lib_HELLO_LISP(cl_object); extern void init_lib_HELLO_LISP(cl_object);
ecl_init_module(NULL, init_lib_HELLO_LISP); ecl_init_module(NULL, init_lib_HELLO_LISP);
cl_eval(c_string_to_object("(hello-lisp)")); cl_object result = cl_eval(c_string_to_object("(hello-lisp)"));
ecl_print(result, ECL_T);
cl_object my_fun = cl_eval(c_string_to_object("(lambda (x) (1+ x))"));
ecl_print(my_fun, ECL_T);
result=cl_funcall(2, my_fun, ecl_make_fixnum(8));
ecl_print(result, ECL_T);
ecl_terpri(ECL_T);
cl_shutdown(); cl_shutdown();
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment