[racket] why an implicit begin to encapsulate the template in syntax-case ?

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Thu Nov 21 21:38:42 EST 2013

The RHS of a syntax-case clause is a code context and not a template.

(syntax-case stx () [_ (displayln "Hey") #'1])

causes a print out when you compile the code, not when it is executed.

You can easily fix your mistake by writing

#'(define #'a #'b)

However, my guess is that you meant

#'(define a b)

all along and just put the #' around a and b because you can't mention
pattern variables outside of syntax patterns.

Jay


On Thu, Nov 21, 2013 at 7:33 PM, Andre Mayers
<Andre.Mayers at usherbrooke.ca> wrote:
> (define-syntax test
>
>   (λ (stx)
>
>     (syntax-case stx ()
>
>       [(_ a b)
>
>        (define #'a #'b)])))
>
> (test a 2)
>
> ;begin (possibly implicit): no expression after a sequence of internal
> definitions
>
> ;(begin (define #'a #'b))
>
>
>
> If you can pinpoint the answer in the reference manual, I will appreciate
> it.
>
>
>
> Thank you
>
>
>
> André
>
>
>
> André Mayers, Ph.D., M. Ps.
>
> professeur agrégé
>
> Département d'informatique
>
> Université de Sherbrooke
>
> Sherbrooke (Québec) Canada J1K 2R1
>
> tél: +1 819-821-8000 poste 62041
>
> fax: +1 819-821-8200
>
> andre.mayers at usherbrooke.ca
>
> http://info.usherbrooke.ca/AndreMayers
>
>
>
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>



-- 
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay

"The glory of God is Intelligence" - D&C 93


Posted on the users mailing list.