racket - PLT Scheme: Converting one of the macros in 'Casting SPELs in LISP' -
(defspel game-action (command subj obj place &rest rest) `(defspel ,command (subject object) `(cond ((and (eq *location* ',',place) (eq ',subject ',',subj) (eq ',object ',',obj) (have ',',subj)) ,@',rest) (t '(i cant ,',command that.)))))
thats code http://www.lisperati.com/actions.html 'macro defining macro'. can't seem convert appropriately scheme. can explain me process of creating same sort of thing in scheme?
this kind of macro simpler in scheme, since can define-syntax-rule
(in standard scheme code need define-syntax
+ syntax-rules
). same thing, minus whole quote/unquote mess.
(defspel (game-action command subj obj place rest ...) (defspel (command subject object) (cond [(and (eq? *location* 'place) (eq? 'subject 'subj) (eq? 'object 'obj) (have 'subj)) rest ...] [else '(i cant command that.)])))
and since of code, ported whole thing plt -- see post on mailing list.
Comments
Post a Comment