The second problem that needs addressing is what to do with closures.

In an FPL, a function value is immutable and execution puts the program
counter on the stack, and values constructed on the stack or heap.

In Felix, procedure values are not immutable: the closure objects  
contain
local variables including the program counter. This means closures
are not re-entrant. Function closures are the same EXCEPT that they
do not include the program counter (which goes on the machine stack).
Since functions in Felix are allowed to contain variables, function
closures aren't re-entrant either.

Felix gets around this by:

a) creating closures on demand as objects of a C++ class
b) cloning a stored closure value.

The latter is expensive. I think I even removed the "clone()" code
(though I can't remember). It is always possible to make a function
generator like:


        gen mk_f() => f ;

which creates a new f closure ever invocation.

Anyhow the problem is the semantics are "unexpected". Generators
deliberately don't get cloned (they're deliberately not re-entrant,
because they're supposed to hold state). But it is surprising
when a function or procedure value isn't re-entrant.

The right solution is to clone "every time" unless it can be proven
that an invocation will terminate before another starts. Unfortunately
that can be hard to do, resulting in higher cost of function value use.


--
john skaller
skal...@users.sourceforge.net





------------------------------------------------------------------------------
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to