[plt-scheme] Avoiding "duplicate definition for identifier" errors

From: Noel Welsh (noelwelsh at gmail.com)
Date: Sat Dec 13 15:08:31 EST 2008

Andre's method is probably the simplest.  Two alternatives:

1. Use keyword arg functions, which allows you to avoid writing your
own dispatch functions
Pro: you don't have to write any dispatch code
Con: your user has to write keywords


2. Expand a define-mission-type into a macro that itself defines
appropriate keywords.

E.g.

(define-syntax define-mission-type
  (syntax-rules ()
    [(_ name (kwd type) ...)
     (define-syntax name
        (syntax-rules (kwd ...)
          [(name arg ...)   dispatch code here]))]))

Pro: user doesn't have to quote keywords
Con: higher-order uses do not work.

HTH,
Noel


Posted on the users mailing list.