From 94e4e9bf04ee356e11765482718e108ff4d5e3bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Kochma=C5=84ski?= Date: Fri, 11 Aug 2017 12:09:04 +0200 Subject: [PATCH] examples: add more C code to embed example Including printing the result and funcalling lambda with arguments. --- examples/embed/hello-lisp.lisp | 4 +++- examples/embed/hello.c | 11 ++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/examples/embed/hello-lisp.lisp b/examples/embed/hello-lisp.lisp index d3134019..67b2d74e 100644 --- a/examples/embed/hello-lisp.lisp +++ b/examples/embed/hello-lisp.lisp @@ -1 +1,3 @@ -(defun hello-lisp () (format t "hello-lisp!~%")) \ No newline at end of file +(defun hello-lisp () + (format t "hello-lisp!~%") + :foo) diff --git a/examples/embed/hello.c b/examples/embed/hello.c index e734871b..3fe9ff28 100644 --- a/examples/embed/hello.c +++ b/examples/embed/hello.c @@ -12,7 +12,16 @@ int main (int argc, char **argv) { extern void init_lib_HELLO_LISP(cl_object); 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(); return 0;