[eeps] Minor incorrect detail in EEP 17

Bjorn Gustavsson bjorn@REDACTED
Wed Aug 13 11:28:11 CEST 2008


When compiling the following code

g(X) when X >= 0 andalso X < 1 -> math:sqrt(X).

from EEP 17 using R12B-3, I get the following code

{function, g, 1, 4}.
  {label,3}.
    {func_info,{atom,t},{atom,g},1}.
  {label,4}.
    {allocate,1,1}.
    {move,{x,0},{y,0}}.
    {test,is_ge,{f,5},[{x,0},{integer,0}]}.
    {test,is_lt,{f,5},[{x,0},{integer,1}]}.
    {move,{y,0},{x,0}}.
    {call_ext_last,1,{extfunc,math,sqrt,1},1}.
  {label,5}.
    {move,{y,0},{x,0}}.
    {deallocate,1}.
    {jump,{f,3}}.

which still has an unnecessary stack frame, but it is better
than the code listed in the EEP. I supposed you must have used
an older compiler.

I am aware that andalso and orelse in guards produce inefficient
code, and I agree that the code quality should be improved.

/Bjorn
-- 
Björn Gustavsson, Erlang/OTP, Ericsson AB



More information about the eeps mailing list