diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2011-12-18 23:13:47 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2011-12-18 23:13:47 -0800 |
commit | 61a8fde2872355b4e721f1c5145c77122c92c40e (patch) | |
tree | 3eb13f0f241b2ebd565cd2ba716d207c63451083 /lib.c | |
parent | 595e55ff7fd02106e7e04bd0db3c2737643fedbd (diff) | |
download | txr-61a8fde2872355b4e721f1c5145c77122c92c40e.tar.gz txr-61a8fde2872355b4e721f1c5145c77122c92c40e.tar.bz2 txr-61a8fde2872355b4e721f1c5145c77122c92c40e.zip |
* eval.c (bindings_helper): Fix format arguments.
(eval_init): Registered new functions: symbol-function,
func-get-form, func-get-env, functionp, interp-fun-p.
* lib.c (nappend2, getplist_f, improper_plist_to_alist):
tail variable renamed to avoid clash in macro.
(func_get_form, func_get_env, interp_fun_p): New functions.
* lib.h (func_get_form, func_get_env, interp_fun_p): Declared.
(list_collect): Fix macro not to throw error, but handle the case.
* match.c (vars_to_bindings, extract_bindings): tail variable
renamed to avoid clash in macro.
* txr.1: Documentation stubs.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 34 |
1 files changed, 27 insertions, 7 deletions
@@ -393,10 +393,10 @@ val nappend2(val list1, val list2) val ldiff(val list1, val list2) { - list_collect_decl (out, tail); + list_collect_decl (out, ptail); while (list1 && list1 != list2) { - list_collect (tail, car(list1)); + list_collect (ptail, car(list1)); list1 = cdr(list1); } @@ -763,12 +763,12 @@ val getplist_f(val list, val key, val *found) val proper_plist_to_alist(val list) { - list_collect_decl (out, tail); + list_collect_decl (out, ptail); for (; list; list = cdr(cdr(list))) { val ind = first(list); val prop = second(list); - list_collect (tail, cons(ind, prop)); + list_collect (ptail, cons(ind, prop)); } return out; @@ -776,16 +776,16 @@ val proper_plist_to_alist(val list) val improper_plist_to_alist(val list, val boolean_keys) { - list_collect_decl (out, tail); + list_collect_decl (out, ptail); for (; list; list = cdr(list)) { val ind = first(list); if (memqual(ind, boolean_keys)) { - list_collect (tail, cons(ind, t)); + list_collect (ptail, cons(ind, t)); } else { val prop = second(list); - list_collect (tail, cons(ind, prop)); + list_collect (ptail, cons(ind, prop)); list = cdr(list); } } @@ -1888,6 +1888,21 @@ val func_interp(val env, val form) return obj; } +val func_get_form(val fun) +{ + type_check(fun, FUN); + if (fun->f.functype != FINTERP) + uw_throwf(error_s, lit("func_get_form: ~a is not an interpreted function"), + fun, nao); + return fun->f.f.interp_fun; +} + +val func_get_env(val fun) +{ + type_check(fun, FUN); + return fun->f.env; +} + val functionp(val obj) { if (!obj) { @@ -1898,6 +1913,11 @@ val functionp(val obj) } } +val interp_fun_p(val obj) +{ + return (functionp(obj) && obj->f.functype == FINTERP) ? t : nil; +} + val funcall(val fun) { type_check(fun, FUN); |