[erlang-questions] Reia - Python/Ruby mix targeting Beam/HiPE
Mikael Pettersson
mikpe@REDACTED
Thu Jun 5 15:19:06 CEST 2008
Bjorn Gustavsson writes:
> "Gleb Peregud" <gleber.p@REDACTED> writes:
>
> > According to http://wiki.reia-lang.org/wiki/Roadmap :
> > The First Milestone: Compile to Erlang AST
> > And I assume that Erlang AST does not permit mutable variables, hence
> > it will probably not include mutable variables (unless hidden by Reia
> > -> Erlang AST translator)
>
> It should be trivial to implement mutable variables, simply by inventing
> a new, unused variable name each time a mutable variable is assigned.
> (Further references to the mutable variable should be changed to refer
> to the new name, of course.)
Define "mutable variable". I know of (at least) two different kinds:
1. Each variable binding starts a new scope, nested within but
otherwise independent of the previous/surrounding scope.
This is what SML's LET and Scheme's LET* implement.
It's still purely functional and can be implemented via
a simple renaming operation (alpha conversion).
2. A variable is bound to an updateable memory cell, and assignment
updates that cell, like in C/Pascal/etc. If these cells can escape
(e.g. via closures), then simple renaming doesn't suffice, and
you're really forced to have a mutable store. Stores can be
emulated in the Erlang VM, but it won't be cheap.
More information about the erlang-questions
mailing list