[erlang-questions] Reassigning variables

Tony Arcieri <>
Thu Mar 19 22:57:06 CET 2009


On Thu, Mar 19, 2009 at 11:18 AM, James Hague <> 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.

-- 
Tony Arcieri
medioh.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090319/989ae614/attachment.html>


More information about the erlang-questions mailing list