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

From: Greg Hendershott (greghendershott at gmail.com)
Date: Thu Nov 8 10:06:57 EST 2012

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.

Posted on the users mailing list.