[plt-scheme] Macro troubles

From: Noel Welsh (noelwelsh at gmail.com)
Date: Mon Jun 23 16:30:25 EDT 2008

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)]
     (printf "Don't know what to do with ~a\n" else)]))

  'player "Please Sir! Can I have some more?"
  'show-item "soup")

  'player "Please Sir! Can I have some more?"
  'show-item "soup"
  'unknown "foo-bar")


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)....

Posted on the users mailing list.