On 17/04/2008, <b class="gmail_sendername">Dimitry Golubovsky</b> <<a href="mailto:golubovsky@gmail.com">golubovsky@gmail.com</a>> wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br> <br> Would be there any difference in compilation/execution of bytecode of<br> these two Erlang Core expressions:<br> <br> 1. foo(bar(_a))<br> <br> 2. let _b = bar(_a) in foo(_b)<br> <br> In other words, does putting nested expressions in `let' make any<br>
difference for the compiler?<br> <br> Assume that both `foo' and `bar' functions do not have side effects.</blockquote><div><br>One reason (the main reason :-)) the compiler does this is to make explicit the evaluation order of called functions. Erlang is defined to evaluate in a left-to-right order while in Core, if I remember correctly, the order is undefined; therefore the need of explicit ordering.<br>
<br>Note that Core has no problems in compiling the nested forms, as you have noticed. For LFE I don't bother to un-nest it, although I probably should. You should at the resultant code when you deep nesting interlaced with list/tuple creation, the result is quite good.<br>
<br>Robert<br> </div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> Thanks.<br> <br> PS The nested form compiles fine by erlc, however when I look at what<br>
erlc produces when run with +to_core on an Erlang source, there are<br> only `let' forms in the generated Core. My Core files are either<br> hand-written or auto-generated.</blockquote><div><br> </div><br></div><br>