AW: [erlang-questions] Preventing calling some functions

Decker, Nils n.decker@REDACTED
Fri Dec 11 18:39:31 CET 2009


> -----Ursprüngliche Nachricht-----
> Von: erlang-questions@REDACTED 
> [mailto:erlang-questions@REDACTED] Im Auftrag von Kiran Khaladkar
> Gesendet: Freitag, 11. Dezember 2009 16:39
> An: Vlad Dumitrescu
> Cc: Joe Armstrong; Brentley Jones; erlang-questions@REDACTED
> Betreff: Re: [erlang-questions] Preventing calling some functions
> i suggest
> ideal solution could be using spown_opts for setting some 
> flags in VM to define what a process can/cannot do :) for the 
> time being i will have to go ahead with the code transforms 
> as Joe suggested thanks guys,

A while ago while reading "Pure functional data structures" from Chris Okasaki
i tried to find a way to implement them in erlang.

A lot of those structures depend on lazy evaluation. The result of the evaluation
has to replace the deferred value in the original datastructure to avoid evaluating
it many times. This update does not change the meaning but the representation 
of the structure.

>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 possibly
  the GC and other things?
- a "no side effect" mode of evaluation for the funs. Any bifs doing sideeffects, spawn,
  send, get, put would be disallowed. This mode would be nice for untrusted code too...
  (btw: list_to_atom would be disallowed, list_to_existing_atom could be allowed)

This model gets difficult when a datastructure is sent to another process. Probably the
only practical way would be to copy the whole structure (like it is now) and reevaluate
the deferred values in all processes seperately.

Nils Decker


More information about the erlang-questions mailing list