Changes by: Jason J. Hickey (jyh at cs.caltech.edu)
Date: 2007-11-02 12:09:26 -0700 (Fri, 02 Nov 2007)
Revision: 12512
Log message:
This commit makes parameters public (dynamically scoped).
The private policy is unchanged: private variables are not exported.
The problem with private exports is demonstrated by the following program.
f(x) =
incr() =
x = $(add $x, 1)
export
y = 1
incr()
value $x
We would expect this to work, but it can never work with static scoping
because it would either 1) not export $x, or 2) wipe out $y.
With dynamic scope, it works as it does in 0.9.8.5. Note that there is
a potential surprise with curried functions. The same issue comes up
with higher order functions in general.
curry.f(x) =
g(y) =
add($x, $y)
When applied, this will fail with "unbound variable: x" because x is
now out of scope. This should be documented in the Curry section (and
the solution, which is to add "private.x = $x").
------
Also addressed a long-standing issue with lazy primitive functions.
f(x) =
println($x)
x = 1
if(true, $(f $x))
In 0.9.8.5, this will result in the error "x = $`x, infinite loop". The
problem is that lazy primitives implicitly quote their arguments.
if(true, $`(f $x))
This means you actually pass $`x as the argument to f(x), so now
you have x = $`x.
The solution is to use a non-recursive quote ValStringExp. There is
overlapping functionality in the recursive and non-recursive quotes.
We should decide whether we need recursive ones (the main reason to
have them is for anti-quotes $,x).
Note, I'm not quite finished; ValStringExp needs to be a closure.
-------
If you don't like either of these, speak now.