[prev in list] [next in list] [prev in thread] [next in thread]
List: racket-users
Subject: [racket] why an implicit begin to encapsulate the template in syntax-case ?
From: jay.mccarthy () gmail ! com (Jay McCarthy)
Date: 2013-11-22 2:38:42
Message-ID: CAJYbDakUXJaWivAtLjjgquxTZ5Fn5+HjR9Qy=mPV4UzZqkrDVw () mail ! gmail ! com
[Download RAW message or body]
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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic