diff options
-rw-r--r-- | ChangeLog | 16 | ||||
-rw-r--r-- | lib.c | 16 |
2 files changed, 28 insertions, 4 deletions
@@ -1,5 +1,21 @@ 2014-06-17 Kaz Kylheku <kaz@kylheku.com> + * lib.c (generic_funcall): Bugfixes: support symbols. + Removed dubious statement which clamps nargs to the number + of fixed parameters, breaking variadic calls. + Test case: (mapcar 'list '(1 2)) -> ((1) (2)) + Note: generic_funcall is only used when non-function objects + are used as functions; variadic funcalls were not broken. + +2014-06-17 Kaz Kylheku <kaz@kylheku.com> + + * lib.c (generic_funcall): Bugfixes: support symbols. + Removed dubious statement which clamps nargs to the number + of fixed parameters, breaking variadic calls. + Test case: (mapcar 'list '(1 2)) -> ((1) (2)) + +2014-06-17 Kaz Kylheku <kaz@kylheku.com> + * txr.1: Fix broken examples for some and none functions. 2014-06-17 Kaz Kylheku <kaz@kylheku.com> @@ -3456,6 +3456,17 @@ val generic_funcall(val fun, val arg[], int nargs) default: uw_throw(error_s, lit("call: too many arguments")); } + case SYM: + { + val binding = lookup_fun(nil, fun); + if (!binding) { + uw_throwf(error_s, lit("call: symbol ~s has no function binding"), + fun, nao); + abort(); + } + fun = cdr(binding); + } + break; case COBJ: if (fun->co.cls == hash_s) { switch (nargs) { @@ -3481,7 +3492,7 @@ val generic_funcall(val fun, val arg[], int nargs) if (!variadic) { if (nargs < reqargs) uw_throw(error_s, lit("call: missing required arguments")); - + if (nargs > fixparam) uw_throw(error_s, lit("call: too many arguments")); @@ -3521,9 +3532,6 @@ val generic_funcall(val fun, val arg[], int nargs) } else { val arglist = nil; - if (nargs > fixparam) - nargs = fixparam; - if (nargs < reqargs) uw_throw(error_s, lit("call: missing required arguments")); |