Changes by: Jason Hickey (jyh at cs.caltech.edu)
Date: 2005-10-02 19:39:41 -0700 (Sun, 02 Oct 2005)
Revision: 7815
Log message:
Updated Dll.om to use mutable variables. This solution wraps
the entire code into a single function.
I've thought about the alternatives to capturing mutable variables,
but I currently think that the no-capturing policy is the best.
Arguments for:
1. It is simple.
2. It can always be circumvented with explicit initializers,
for example:
mutable.X = foo
private.initialize() =
X = foo
public.g() =
println($"X = $(X)") # fails if called out of scope of X
public.f() =
initialize()
println($"X = $(X)") # prints "X = foo"
3. Mutable variables *never* escape--this is very cool.
Arguments against:
1. Imperative programming is harder than functional, but it
is not clear that the OMake solution is an optimum relative
to the objectives.
2. Performance relative to functional programming can be O(1) worse,
because initializers may be needed.
3. It is unlike other mainstream imperative languages, where
mutable variables are often globally or statically-scoped.