chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] Functions with lots of parameters


From: John Cowan
Subject: Re: [Chicken-users] Functions with lots of parameters
Date: Sat, 21 Oct 2006 19:52:38 -0400
User-agent: Mutt/1.3.28i

Alejandro Forero Cuervo scripsit:

> The first is that they don't work well with lazy evaluation.  Suppose
> you do "(define i (make-parameter 0))".  For what I want (which I
> described in my previous mail), I would expect the following
> expression to evaluate to 1:
> 
>     (force (parameterize ((i 1)) (delay (i))))

Quite true.  Parameters work with dynamic scope, so once you've exited that
(the return from delay) the value of the parameter is forgotten.  You
could capture its value (not the parameter itself) inside the delayed
function, though.

> The other, less important, thing I don't like for this usage of
> parameter objects is that I have to reserve (ie. define) the name I
> want for my parameters globally.  

Actually, you don't.  The appearance of the PARAMETERIZE macro is
deceiving.  The "i" in

        (parameterize ((i 10)) ...)

is not restricted to being a simple variable name, as in the comparable
LET special form.  It can be any expression whatever that evaluates to
a parameter object; specifically, it can be a call on a procedure that
returns the desired parameter object.

This is what (in a single-threaded context) makes parameters better
than FLUID-LET.

-- 
Babies are born as a result of the              John Cowan
mating between men and women, and most          http://www.ccil.org/~cowan
men and women enjoy mating.                     address@hidden
    --Isaac Asimov in Earth: Our Crowded Spaceship




reply via email to

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