[erlang-questions] Core Erlang questions

Robert Virding <>
Fri Oct 17 23:42:05 CEST 2008


2008/10/17 Richard Carlsson <>

> Ulf Wiger wrote:
> > 2008/10/16 Robert Virding <>:
> >> There is a specific reason for the Erlang compiler to return code like
> that.
> >> In Erlang the order of evaluation is defined to be left-to-right
> >
> > Where is this defined?
> >
> > I believe (too tired to check) that the Barklund spec left the
> > evaluation order undefined, with the proviso that no possible
> > evaluation order should leave variables unbound when used.
>
> As far as I can remember, around the time when Barklund wrote that
> spec it was decided that Erlang should have a fixed evaluation order,
> so that there would never be a situation where a program would behave
> slightly different (e.g., a process sending messages in a different
> order, or a different exception being thrown) on an alternative
> implementation. I think some minor things in the compiler were changed
> at that time, to conform to the left-to-right principle. It does
> restrict a bit what the compiler can do, though: only safe expressions
> (free from side effects and exceptions) can be reordered at all.
>

Another reason to explicitly define evaluation order is that you also define
where variables are visible and who binds them and who tests them. This can
get *very* tricky in the general case. Fortunately people usually don't
write that tricky and convoluted code. :-)

Robert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20081017/11c76c55/attachment.html>


More information about the erlang-questions mailing list