From 4d2ab06904fd69c0fc7ba3c5237127726ab5c98b Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 15 Nov 2015 08:13:42 -0800 Subject: Functors: structs callable as functions. * lib.c (generic_funcall): If an object is used as a function, get its lambda method and call that. * txr.1: Document functors. --- lib.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib.c') diff --git a/lib.c b/lib.c index 2771c18d..09e85693 100644 --- a/lib.c +++ b/lib.c @@ -4762,6 +4762,9 @@ val generic_funcall(val fun, struct args *args_in) default: callerror(fun, lit("too many arguments")); } + } else if (structp(fun)) { + fun = method(fun, lambda_s); + break; } /* fallthrough */ default: -- cgit v1.2.3