summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-06-17 22:14:48 -0700
committerKaz Kylheku <kaz@kylheku.com>2014-06-17 22:14:48 -0700
commita3380a6ce354fc956635837d3fbca39b730d73aa (patch)
tree1f3d038022032f816f47d7a5278d2def3041ee16
parentf15dcf205cb43804140db1f59314191e14d7ec65 (diff)
downloadtxr-a3380a6ce354fc956635837d3fbca39b730d73aa.tar.gz
txr-a3380a6ce354fc956635837d3fbca39b730d73aa.tar.bz2
txr-a3380a6ce354fc956635837d3fbca39b730d73aa.zip
* 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.
-rw-r--r--ChangeLog16
-rw-r--r--lib.c16
2 files changed, 28 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 315b1818..8125d80a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
diff --git a/lib.c b/lib.c
index e505225a..96ede9f9 100644
--- a/lib.c
+++ b/lib.c
@@ -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"));