[plt-scheme] define-syntax question

From: Gary L. Pendleton (gpendleton at integra-online.com)
Date: Thu Aug 1 12:08:13 EDT 2002

I'm doing a little work in version 103 with define-syntax and I'm having a
little trouble.  Here's my example and the results.

(require-library "synrule.ss")

(define-syntax d1
  (syntax-rules ()
                ((_ (fun arg1 . rest) pgm ...)
                 'improper-list)
                ((_ (fun arg1 ...) pgm ...)
                 'multi-args)
   ))

(define-syntax d2
  (syntax-rules ()
                ((_ (fun arg1 ...) pgm ...)
                 'multi-args)
                ((_ (fun arg1 . rest) pgm ...)
                 'improper-list)
   ))


Results:

Welcome to DrScheme, version 103p1.
Language: Graphical Full Scheme (MrEd) Custom.
> (d1 (x a b c) a)
improper-list
> (d2 (x a b c) a)
multi-args
> (d1 (x a . b) a)
improper-list
> (d2 (x a . b) a)
 andmap: expects type <proper list> as 2nd argument, given: (a . b); other
arguments were: #<procedure>
>
My question is this.  How do I uniquely identify an improper list verses
multiple arguments.  d1 works half the time and d2 works the other half, but
I need to have a solution that works all of the time.  I know how to do it
in the 200 version with the use of syntax-case and fenders, but I need to be
able to support 103.



Thanks,

Gary L. Pendleton
Integra Software Systems, LLC
Phone: (615) 595-0900  Ext. 803
Cell: (615) 394-6754
Fax: (615) 628-0100
Email: gpendleton at integra-online.com






-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20020801/19141d19/attachment.html>

Posted on the users mailing list.