[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] On parameterize and fluid-let
From: |
Kon Lovett |
Subject: |
Re: [Chicken-users] On parameterize and fluid-let |
Date: |
Sun, 14 Oct 2007 11:05:12 -0700 |
On Oct 14, 2007, at 10:05 AM, John Cowan wrote:
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.
It is implemented as above, except for the 'dynamic-wind' safety.
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.
It will bind globals also, uses '##sys#set!'. Also uses 'dynamic-wind'.
--
Even the best of friends cannot John Cowan
attend each others' funeral. address@hidden
--Kehlog Albran, The Profit http://www.ccil.org/
~cowan
_______________________________________________
Chicken-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/chicken-users
Best Wishes,
Kon
Message not available