diff --git a/prometheus-impl.scm b/prometheus-impl.scm index 5613a01..06aa027 100644 --- a/prometheus-impl.scm +++ b/prometheus-impl.scm @@ -111,39 +111,50 @@ (define-syntax define-method (syntax-rules () - ((_ (obj 'message self resend args ...) + ((_ (obj message self resend args ...) body1 body ...) - (obj 'add-method-slot! 'message + (obj 'add-method-slot! `message (lambda (self resend args ...) body1 body ...))))) (define-syntax define-object (syntax-rules () ((_ name (creation-parent (parent-name parent-object) ...) - slots ...) + slot ...) (define name (let ((o (creation-parent 'clone))) - (o 'add-parent-slot! 'parent-name parent-object) + (o 'add-parent-slot! `parent-name parent-object) + ... + (define-object/add-slot! o slot) ... - (define-object/add-slots! o slots ...) o))))) -(define-syntax define-object/add-slots! - (syntax-rules () - ((_ o) - (values)) - ((_ o ((method-name . method-args) body ...) - slots ...) - (begin - (o 'add-method-slot! 'method-name (lambda method-args - body ...)) - (define-object/add-slots! o slots ...))) - ((_ o (slot-getter slot-setter slot-value) - slots ...) - (begin - (o 'add-value-slot! 'slot-getter 'slot-setter slot-value) - (define-object/add-slots! o slots ...))) - ((_ o (slot-getter slot-value) - slots ...) - (begin - (o 'add-value-slot! 'slot-getter slot-value) - (define-object/add-slots! o slots ...))))) +(define-syntax define-object/add-slot! + (syntax-rules (unquote) + ; unquoted + ((_ o ((,method-name . method-args) + body ...)) + (o 'add-method-slot! method-name (lambda method-args + body ...))) + + ((_ o (,slot-getter ,slot-setter slot-value)) + (o 'add-value-slot! slot-getter slot-setter slot-value)) + + ((_ o (slot-getter ,slot-setter slot-value)) + (o 'add-value-slot! 'slot-getter slot-setter slot-value)) + + ((_ o (,slot-getter slot-setter slot-value)) + (o 'add-value-slot! slot-getter 'slot-setter slot-value)) + + ((_ o (,slot-getter slot-value)) + (o 'add-value-slot! slot-getter slot-value)) + + ; not unquoted + ((_ o ((method-name . method-args) body ...)) + (o 'add-method-slot! 'method-name (lambda method-args + body ...))) + + ((_ o (slot-getter slot-setter slot-value)) + (o 'add-value-slot! 'slot-getter 'slot-setter slot-value)) + + ((_ o (slot-getter slot-value)) + (o 'add-value-slot! 'slot-getter slot-value))))