
Untitled
By: a guest on
Aug 19th, 2012 | syntax:
None | size: 0.52 KB | hits: 7 | expires: Never
(define-syntax-rule (defobject (name) slot1 ...)
(begin
(define (name msg)
#|TODO: derive this from the slots of the root object, which would include clone,
to-string, etc|#
(define slots (make-hash))
;;;This internal macro is currently useless
(define-syntax-rule (self x) (hash-ref slots 'x))
(for ([s '(slot1 ...)])
(hash-set! slots (first s) (eval (last s))))
(hash-ref slots msg))))
(defobject (posn)
[x 2]
[y x]
[add (λ() (+ (posn 'x) (posn 'y)))])