[erlang-questions] Core Erlang questions
Robert Virding
rvirding@REDACTED
Thu Oct 16 13:59:36 CEST 2008
2008/10/16 Lars-Åke Fredlund <lfredlund@REDACTED>
>
> Thank you for the explanation, which made the definition much more clearer.
>
> Anyway I wasn't worrying, I was rather hoping :-) that it was
> impossible to have very
> "complicated" expressions. In a sense having a very simple input format
> where "computation" (calling functions, receive, case, etc) of
> expressions only takes place in let arguments, and the let body only
> composes basic values and variables using simple data constructors. The
> Core Erlang output from compile:file (with option 'to_core') seems (in
> my limited testing experience) to respect this.
As Richard said you can basically have full expressions everywhere. One
thing to note about returning multiple values is that the compiler makes
very few checks of their consistency, it does some internally within a
module but none between modules. It is assumed you only return one value.
Multiple values were added as a way of handling the export of variables from
if/case/receive in Erlang.
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 while in
Core Erlang no order of evaluation is defined. So to be certain the Erlang
compiler explictily sequentialises the evaluation of code by using nested
lets. The only problem with this is that some of the Core optimisation
modules "assume" that the Core code has been generated like this. I
discovered this doing LFE, which generates Core, and while I have only
discovered two bugs (fixed in subsequent releases) I do miss out on some
optimisations. :-( The way around this is to do the same sequentialisation
as the Erlang compiler, which would be right anyway, bit it seems so
negative. :-)
Robert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20081016/d456d5b5/attachment.htm>
More information about the erlang-questions
mailing list