From 04a75123fc2f6135850a811bf7477ed97fdcdc83 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 5 Feb 2014 17:10:11 -0800 Subject: Allow sequences and hashes to be called as functions. This is already supported in the DWIM operator. * eval.c (apply): If object isn't a function, gather the arguments into an array and delegate to generic_funcall. * lib.c (generic_funcall): Changed from static to external linkage. Supports sequences and hashes as functions. Error messages fixed not to refer to "funcall". (funcall, funcall1, funcall2, funcall3, funcall4): Do not throw exception if fun is not of FUN type; instead, delegate to generic_funcall. Error messages fixed not to refer to "funcall". * lib.h (generic_function): Declared. --- eval.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'eval.c') diff --git a/eval.c b/eval.c index 61459838..a70d8474 100644 --- a/eval.c +++ b/eval.c @@ -340,6 +340,16 @@ val apply(val fun, val arglist, val ctx_form) fun = cdr(binding); } + if (!functionp(fun)) { + for (nargs = 0; + (p < arg + 32) && consp(arglist); + nargs++, p++, arglist = cdr(arglist)) + { + *p = car(arglist); + } + return generic_funcall(fun, arg, nargs); + } + type_check (fun, FUN); if (!listp(arglist)) { -- cgit v1.2.3