[erlang-questions] Reassigning variables
Thu Mar 19 22:57:06 CET 2009
On Thu, Mar 19, 2009 at 11:18 AM, James Hague <james.hague@REDACTED> wrote:
> You can ALREADY simulate imperative updates using function calls (see
> http://prog21.dadgum.com/5.html). Adding some syntactic sugar to make
> this easiest is a good thing.
You can also implement destructive assignments with a parse transform by
adding version numbers to variables and incrementing the version number
whenever they are used in match expressions, which is how Reia works. This
approach is a bit trickier than it sounds as there are various scopes (e.g.
lambdas, list comprehensions) where your transform needs to act differently
than it would otherwise.
Again, I would not recommend using this to add destructive updates to
Erlang. In my totally unbiased opinion, if someone really has a hankering
for doing destructive assignments I suggest you point them at Reia.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions