From 2d173febd859a05708e14273397df61f75bea895 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 9 Oct 2016 19:08:02 -0700 Subject: Support curried args in method and meth. * share/txr/stdlib/struct.tl (meth): Take trailing arguments and pass them down to method, which now accepts them. * struct.c (struct_init): Register method intrinsic to the function method_args instead of the method function. (method_args_fun): New static function. (method_args): New function. Behaves like method function if args is empty, otherwise creates a function by means of method_args_fun. * struct.h (method_args_fun): Declared. * tests/012/oop.tl: New test case. * tests/012/oop.expected: Updated. * txr.1: Documented new features in method and meth, revising the documentation in the process. --- 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 9f643662..ecd1db5d 100644 --- a/share/txr/stdlib/struct.tl +++ b/share/txr/stdlib/struct.tl @@ -230,8 +230,8 @@ (list ,*args))))) (atom ^(make-lazy-struct ',atom (lambda () (list (list ,*qpairs)))))))) -(defmacro meth (obj slot) - ^(method ,obj ',slot)) +(defmacro meth (obj slot . bound-args) + ^[(fun method) ,obj ',slot ,*bound-args]) (defmacro usl (slot) ^(uslot ',slot)) -- cgit v1.2.3