[plt-scheme] Confused by local

From: Greg Woodhouse (gregory.woodhouse at sbcglobal.net)
Date: Thu Feb 9 19:04:23 EST 2006

Looking in the help desk, I see the following definition of local:



The local expression is used to group together related definitions.
Each definition in the local is evaluated in order, and finally the
body expression is evaluated. Only the expressions within the local
(including the right-hand-sides of the definitions and the body) may
refer to the names defined by the local. If a name defined in the local
is the same as a top-level binding, the inner one "shadows" the outer
one. That is, inside the local, any references to that name refer to
the inner one.

buyt there is no indication (that I can find) of what to do with
(DEFINITION ...). This looks an awful lot like let and related
constructs, but I only get an error when using that syntax

Welcome to DrScheme, version 301.
Language: PLAI - Pretty Big.
> (let ((x 3)) x)
> (local ((x 3)) x)
local: not a definition in: (x 3)

But constructs like

(local (define ...) ...)

don't even parse.

What is the proper syntax, and how is this different from let, letrec,
et al.?

Gregory Woodhouse  <gregory.woodhouse at sbcglobal.net>
"All truth passes through three stages: First, it is ridiculed.
Second, it is violently opposed. Third, it is accepted as
being self-evident."
--Arthur Schopenhauer

Posted on the users mailing list.