[plt-scheme] let vs parameterize?

From: Carl Eastlund (cce at ccs.neu.edu)
Date: Mon Apr 16 16:21:38 EDT 2007

On 4/16/07, Yin-So Chen <yinso.chen at gmail.com> wrote:
> What is the difference between using let vs parameterize?

Let operates on bindings.  It creates a new name and binds it to a
value.  This affects code directly within the let-body that refers to
the same name, providing it is not bound again ("shadowed") inside the
let.

Parameterize operates on parameters, which are values.  It takes an
existing parameter and makes it return a different value during the
execution of the body of the parameterize.  This affects any code
called during that execution, even if it's in a different function,
module, whatever, so long as it uses the same parameter value.

> It seems that one can use let to manipulate parameter objects (at least
> scheme doesn't forbid it) - any issues with using it?

Let does not manipulate values at all.  It just binds names to
existing values.  It never changes values or their contents.

>  How do I know whether or not something is a parameter versus a variable?

You could ask the same thing about numbers vs variables, or strings vs
variables.  A variable is a name for a value.  That value might be
anything: number, string, list, parameter, etc.  But you should be
careful never to confuse the name with what it refers to.

And in response to the followup email: fluid-let, like let, operates
on variables (names), not values.  Hence it would not be an
"extension" to make it work on parameters.  If you give the name of a
parameter to fluid-let, it will change which parameter that name
refers to, not the contents of the current parameter.

-- 
Carl Eastlund


Posted on the users mailing list.