chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] On parameterize and fluid-let


From: John Cowan
Subject: Re: [Chicken-users] On parameterize and fluid-let
Date: Sun, 14 Oct 2007 13:05:45 -0400
User-agent: Mutt/1.5.13 (2006-08-11)

Tobia Conforto scripsit:

> Question: does (parameterize) have any hidden or special meaning that's
> not obvious?  Are these two forms equivalent, except maybe for the
> introduction of a few symbols?
> 
> (parameterize ((param1 value1) ...)
>   body ...)
> 
> (let ((old-value1 (param1)) ...)  ;save parameters
>   (param1 value1) ...             ;change parameters
>   (let ((ret (begin body ...)))   ;execute body and save return value
>     (param1 old-value1) ...       ;restore parameters
>     ret))                         ;return value
> 
> Is (parameterize) just a handy macro for the latter form?

If you use parameters only in the "standard" way, then it can appear so.
But parameters are first-class objects, lexical variables are not.
In (parameterize ((n1 v1) (n2 v2) ...) ...), the n1, n2, ...  are general
Scheme expressions that evaluate to parameter objects, not names.
In the typical use, global variables are permanently bound to parameter
objects, and then the global variable is an expression which evaluates
to the parameter object.  But you can equally well have parameter-valued
procedures or procedures which accept parameters as arguments.

Although parameters are defined by SRFI-39 (see
http://srfi.schemers.org/srfi-39/srfi-39.html ), their interaction with
threads is not.  Different Schemes may make parameters thread-global,
thread-local with copying (like Chicken) or thread-local but uninitialized
in new threads.

> (fluid-let), on the other hand, operates on non-thread-local variables,
> so its effect is very different from these two forms.  Is this correct?

Fluid-let really is what you thought parameters were: just a hack to
shallow-bind local variables.  Its behavior in the presence of non-local
transfers of control can't be counted on.

-- 
Even the best of friends cannot                 John Cowan
attend each others' funeral.                    address@hidden
        --Kehlog Albran, The Profit             http://www.ccil.org/~cowan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]