[erlang-questions] Erlang Core question: nested expressions vs. let?

Richard Carlsson <>
Thu Apr 17 17:59:05 CEST 2008


Dimitry Golubovsky wrote:
> Would be there any difference in compilation/execution of bytecode of
> these two Erlang Core expressions:
> 
> 1.  foo(bar(_a))
> 
> 2. let _b = bar(_a) in foo(_b)
> 
> In other words, does putting nested expressions in `let' make any
> difference for the compiler?

No, the resulting BEAM code or native code will be the same. Variables
are just temporary names and have no fixed correspondence with storage
cells in memory. The compiler splits them into separate let-expressions
for various reasons, but that has no effect on performance.

> Assume that both `foo' and `bar' functions do not have side effects.

That makes no difference in this case.

     /Richard





More information about the erlang-questions mailing list