From 0bb1f829c745d94386f17f37ed5568a20c7243e9 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 9 Oct 2016 10:46:03 -0700 Subject: Support curried arguments in umethod and umeth. * share/txr/stdlib/struct.tl (umeth): accept variadic arguments. Evaluate them using the dwim brackets and pass to umethod. The (fun umethod) trick is used to refer to the umethod in the function namespace even if it is shadowed by a variable. * struct.c (struct_init): Update registration of umethod to reflect its new variadic argument signature. (umethod_args_fun): New static function. (umethod): Return a function based on umethod_fun, as before, if there are no variadic args. Otherwise, use umethod_args_fun which deals with them. * struct.h (umethod): Declaration updated. * tests/012/oop.tl: Modest testcase for umeth with curried argument. * tests/012/oop.expected: Updated. * txr.1: Updated documentation of umeth and umethod. --- share/txr/stdlib/struct.tl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'share') diff --git a/share/txr/stdlib/struct.tl b/share/txr/stdlib/struct.tl index e79dd3ed..9f643662 100644 --- a/share/txr/stdlib/struct.tl +++ b/share/txr/stdlib/struct.tl @@ -236,8 +236,8 @@ (defmacro usl (slot) ^(uslot ',slot)) -(defmacro umeth (slot) - ^(umethod ',slot)) +(defmacro umeth (slot . bound-args) + ^[(fun umethod) ',slot ,*bound-args]) (defun sys:defmeth (type-sym name fun) (let ((type (find-struct-type type-sym))) -- cgit v1.2.3