diff options
-rw-r--r-- | share/txr/stdlib/struct.tl | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/share/txr/stdlib/struct.tl b/share/txr/stdlib/struct.tl index 8eb4d35c..5165fd29 100644 --- a/share/txr/stdlib/struct.tl +++ b/share/txr/stdlib/struct.tl @@ -209,9 +209,12 @@ (defmacro umeth (slot) ^(umethod ',slot)) +(defun sys:defmeth (type-sym name fun) + (let ((type (find-struct-type type-sym))) + (if type + (static-slot-ensure type-sym name fun) + (throwf 'eval-error "~s: ~s isn't a struct type" 'defmeth type-sym)))) + (defmacro defmeth (type-sym name arglist . body) - ^(progn - (static-slot-ensure (find-struct-type ',type-sym) ',name - (lambda ,arglist - (block ,name ,*body))) - ',name)) + ^(sys:defmeth ',type-sym ',name (lambda ,arglist + (block ,name ,*body)))) |