Hi,

I'm starting to play with syntax-parse. Looks really great, but also quite 
complex.

Here are some newbie questions. 
(the example is based on the defmac of Eli)

I use two optional declaration:

(define-syntax (defmac2 stx)
  (syntax-parse stx
    [(defmac2 (name:identifier . xs) 
       (~optional (~seq #:keywords key:identifier ...))
       (~optional (~seq #:captures cap:identifier ...))
       body:expr)
 #'(define-syntax (name stx)
     (syntax-case stx (key ...)
       [(name . xs)
        (with-syntax ([cap (datum->syntax stx 'cap stx)] ...)
          (syntax body))]))])))


1. according to the docs, I can pass #:name in an ~optional.
if I do so:
(~optional (~seq #:keywords key:identifier ...) #:name "foo")
I get:
~optional: unexpected keyword, expected one of (#:defaults) in: #:name
(according to the docs there are 3 keywords for optional, name, too-many, and 
defaults)

2. my macro above works ok only if both #:keywords and #:captures are given, 
because if they are not, the key and cap variables get bound to #f.
And I get messages like:
key: attribute is bound to non-syntax value: #f in: key

I therefore want to specify a default that is more reasonable than #f in my 
case. I looked into the #:defaults parameter of ~optional, but unsuccessfully.
I don't know how to have it behave as I'd expect, that is, if none is given, 
then key ... is "zero occurrences". 

Any help is greatly appreciated!

Thanks,


-- Éric



_________________________________________________
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users

Reply via email to