[plt-scheme] Re: misplaced ellipses
On Feb 26, 2008, at 3:41 PM, David Van Horn wrote:
> Matthew Flatt wrote:
>> At Tue, 26 Feb 2008 13:48:45 -0500, David Van Horn wrote:
>>> (define-syntax f
>>> (syntax-rules ()
>>> [(f id)
>>> (syntax (... id))]))
>>>
>>> (f ...)
>>> ;; expect (syntax (... ...)),
>>> ;; ie., the identifier `...'.
>>>
>>>
>>> I get instead:
>>>
>>> syntax: misplaced ellipses in template in: ...
>>>
>>> Why is this the case?
>> The macro `(f ...)' expands to `(syntax ...)', which is indeed a
>> syntax
>> error.
>
> If the syntax-rule is
>
> (f id) =transcribe=> (syntax (... id))
>
> I would expect (f ...) =transcribe> (syntax (... ...)), which is not a
> syntax error.
>
>> I think you meant
>> (define-syntax f
>> (syntax-rules ()
>> [(f id)
>> (... id)])) ; no `syntax'
>
> No, I want a macro that takes an identifier, expands into an
> expression that when evaluated, produces the syntax object
> representing the identifier (even when this identifier is the ...
> one).
>
> So for example (identifier? (f x)) is true.
Matthew already explained how to do ellipsis-escaping with 'syntax',
but another good tool to be aware of is 'quote-syntax':
(define-syntax f
(syntax-rules ()
[(f id)
(quote-syntax id)]))
Ryan
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme