compiler question ?

Bjorn Gustavsson <>
Wed Oct 11 17:42:49 CEST 2000


> is the compiler smart enough to detect that something is unchanged, and then 
> not copy it again ( on stacks, or whatever )
> f(A) ->2* g(A).
> is A copied on the stack, or just passed around ? ( Ais big in my case, and 
> quite deep recursion is happenning)

The Beam compiler only saves variables on the stack if they will actually
be used later in the same function. In your case, A will not be saved on
the stack.

> generally speaking , in FP , are things passed around as values or pointer ?

It depends on the type. In Erlang we use 32 bits words that can contain
either a value (for instance an integer or an atom), or pointer to complex
terms likes list cells or tuples. In both cases there a tag bits that
indicates the type.

Björn Gustavsson            Ericsson Utvecklings AB
			    BOX 1505
+46 8 727 56 87 	    125 25 Älvsjö

More information about the erlang-questions mailing list