[racket] An example of let-vs-define: SICP 2.64

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Thu Nov 8 12:36:08 EST 2012

That happens to the best and worst of us. I switch among 
syntax-rule, syntax-rules, syntax-case, and syntax-parse. 
I have made the same mistake as your friend. 







On Nov 8, 2012, at 10:06 AM, Greg Hendershott wrote:

> In general I love internal define and have been using it heavily.
> 
> After the initial infatuation, I still love it. I've also come to
> appreciate that sometimes let can be clearer. I like having the
> choice.
> 
> Another way internal define can bite you is if you're not real crisp
> on your understanding of certain forms with optional parts. For
> instance syntax-case clauses. Let's say I have a friend (ahem) who
> didn't really grok the optional guard/fender part, but that hadn't
> mattered when writing stuff like:
> 
> (syntax-case stx ()
>  [(_ my pattern)
>   (let ([id rhs])
>     #'(my template))])
> 
> One day tries:
> 
> (syntax-case stx ()
>  [(_ my pattern)
>   (define id rhs)
>   #'(my template)])
> 
> This friend of mine (cough) was confused for awhile before figuring it out.
> 
> Of course the primary problem here is me^H^H my friend didn't know
> this aspect of syntax-case clauses. I'm just saying that switching
> from let to define can flush out some misunderstandings. Shrug.
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4373 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20121108/991b33d2/attachment-0001.p7s>

Posted on the users mailing list.