From 5fb5509d8d5a4bb0646b1beb083be6b6a6ec55d1 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 16 Oct 2015 21:47:12 -0700 Subject: Adding defmeth macro and static-slot-ensure. * share/txr/stdlib/struct.tl (defmeth): New macro. * struct.c (struct struct_type): New member, dvtypes. (struct_init): Register static-slot-ensure intrinsic. (make_struct_type): Initialize dvtypes of newly instantiated struct_type struct. If a super is specified, add new type to the super's dvtypes. (struct_type_mark): Mark st->dvtypes. (static_slot_ensure): New function. * struct.h (static_slot_ensure): Declared. * txr.1: Documented defmeth and static-slot-ensure. --- share/txr/stdlib/struct.tl | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'share') diff --git a/share/txr/stdlib/struct.tl b/share/txr/stdlib/struct.tl index 7213d9eb..34e9bb07 100644 --- a/share/txr/stdlib/struct.tl +++ b/share/txr/stdlib/struct.tl @@ -193,3 +193,10 @@ (defmacro umeth (slot) ^(umethod ',slot)) + +(defmacro defmeth (type-sym name arglist . body) + ^(progn + (static-slot-ensure (find-struct-type ',type-sym) ',name + (lambda ,arglist + (block ,name ,*body))) + ',name)) -- cgit v1.2.3