AW: [erlang-questions] Preventing calling some functions
Mon Dec 14 00:33:28 CET 2009
On Dec 12, 2009, at 6:39 AM, Decker, Nils wrote:
> From my point of view two things would be needed:
> - a way to replace a fun () -> ... end somewhere in the
> datastructure with the
> result of this function. This breaks erlangs immutable values and
> the GC and other things?
That's not really what you want. What you want is more like
Scheme's (delay Expression), not a fun. (There is, after all,
a big difference between an unevaluated expression that evaluates
to a fun and the fun it evaluates to.) And you want pattern matching
and a bunch of built-ins to to automatically (force -) delayed
expressions. As in Scheme, the run-time representation of a delayed
expression might _contain_ a fun, but that's not the same as _being_
However, graph rewriting does boil down to destructively updating a
data structure at run time, and yes, that could give some Erlang
garbage collectors trouble.
Perhaps before such changes are made to Erlang we should look for
efficient data structure that _don't_ rely on lazy evaluation.
I once proposed a -pure([f/n, ...]) declaration to Fergus O'Brien,
inspired by the ?-pure directive in NU Prolog. Tracking this through
code changes seemed like more trouble than it was worth, at the time.
> - a "no side effect" mode of evaluation for the funs. Any bifs doing
> sideeffects, spawn,
> send, get, put would be disallowed.
Purity checked at *compile time* is far nicer, because it means you
only need the one evaluation mode and don't have to spend any time at
all checking at run time.
More information about the erlang-questions