[plt-scheme] why local? (just curious)
Sigrid Keydana wrote:
> [...]
> I remember having seen the "local" form in HDTP, but I'd thought it was
> for learning purposes only. Now I see it's used in the Continue Guide
> I'm working through and it's part of standard (PLT) scheme. I just
> wonder why it's necessary (or even "nice-to-have") - why not simply use
> let or letrec?
> [...]
Hello,
the local form is handy if you want to define a set of local functions
that are mutually recursive. You can write those with the same syntax as
on the module level inside local. In addition to define, the forms
define-syntax and define-struct are also valid inside local.
Of course you can always use a combination of letrec and let-syntax to
the same effect as local, but the syntax is more verbose. It's really a
matter of taste which you like better.
cu,
Thomas