[plt-scheme] Macro troubles
I really don't see any advantage in implementing this as macros, and
indeed you get yourself a whole heap of extra issue to figure out. It
seems that you could implement this fairly simply with match:
#lang scheme
(define (commands . args)
(match args
[(list) (display "I'm done\n")]
[(list-rest 'player sentence rest)
(printf "Player says: ~a\n" sentence)
(apply commands rest)]
[(list-rest 'show-item item rest)
(printf "You see: ~a\n" item)
(apply commands rest)]
[else
(printf "Don't know what to do with ~a\n" else)]))
(commands
'player "Please Sir! Can I have some more?"
'show-item "soup")
(commands
'player "Please Sir! Can I have some more?"
'show-item "soup"
'unknown "foo-bar")
HTH,
N.
On Mon, Jun 23, 2008 at 8:53 PM, Killian McCutcheon <entarter at gmail.com> wrote:
> I'm having a bit of trouble re-implementing a DSL using macros (I'm a macro
> newbie)....