On Oct 2, 2014, at 6:53 PM, Ryan Culpepper <ry...@ccs.neu.edu> wrote:

> On 10/02/2014 09:19 PM, Kevin Forchione wrote:
>> Hi guys,
>> Why does this appear to work? I assume it’s not a recommended approach.
>> 
>> #lang racket
>> 
>> (require (for-syntax syntax/parse))
>> 
>> (define-syntax (mylet stx)
>>   (let ([val (syntax-case stx ()
>>                [(_ x) #'x]
>>                [(_ x xs ...) #'(cons x (mylet xs ...))])])
>>     val))
>> 
>> (mylet 1 2 3) => ‘(1 2 3)
> 
> It doesn't return '(1 2 3); it returns '(1 2 . 3).
> 
> Other than that, the let is unnecessary, but it's just a straightforward 
> recursive macro.
> 
> Maybe the answer to your question is that syntax-case is nothing special; 
> it's basically a version of match specialized to dealing with syntax objects. 
> You can use it inside of other expressions. 
> Seehttp://www.greghendershott.com/fear-of-macros/ for an explanation of how 
> not-special syntax-case is.

Sorry about the typo. Yes, ‘(1 2 . 3). I was surprised that wrapping a let 
around the syntax-case worked.  But I suppose that define-syntax behaves 
similarly to define? In other words I could have any number expressions within 
the body of the define-syntax, manipulating syntax objects?

-Kevin
____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Reply via email to