# Old style vs. new style boolean expressions

James Hague jamesh@REDACTED
Tue Oct 8 22:49:11 CEST 2002


> (I only have R7 at hand, so no andalso, orelse). And run the compiler
> on that, like this:

Here it is under R8:

f3(N) ->
	((N >= $A) andalso (N =< $Z)) orelse
	((N >= $a) andalso (N =< $z)) orelse
	((N >= $0) andalso (N =< $9)) orelse
	(N == $_).

which generates the following monstrosity:

{function, f3, 1, 10}.
  {label,9}.
    {func_info,{atom,f},{atom,f3},1}.
  {label,10}.
    {allocate_zero,1,1}.
    {bif,'>=',{f,0},[{x,0},{integer,65}],{x,1}}.
    {move,{x,0},{y,0}}.
    {test,is_atom,{f,41},[{x,1}]}.
 
{select_val,{x,1},{f,41},{list,[{atom,true},{f,11},{atom,false},{f,14}]}}.
  {label,11}.
    {bif,'=<',{f,0},[{x,0},{integer,90}],{x,1}}.
    {test,is_atom,{f,41},[{x,1}]}.
 
{select_val,{x,1},{f,41},{list,[{atom,true},{f,12},{atom,false},{f,13}]}}.
  {label,12}.
    {move,{atom,true},{x,0}}.
    {'%live',1}.
    {jump,{f,15}}.
  {label,13}.
    {move,{atom,false},{x,0}}.
    {'%live',1}.
    {jump,{f,15}}.
  {label,14}.
    {move,{atom,false},{x,0}}.
    {'%live',1}.
  {label,15}.
    {test,is_atom,{f,40},[{x,0}]}.
 
{select_val,{x,0},{f,40},{list,[{atom,false},{f,16},{atom,true},{f,39}]}}.
  {label,16}.
    {bif,'>=',{f,0},[{y,0},{integer,97}],{x,0}}.
    {test,is_atom,{f,42},[{x,0}]}.
 
{select_val,{x,0},{f,42},{list,[{atom,true},{f,17},{atom,false},{f,20}]}}.
  {label,17}.
    {bif,'=<',{f,0},[{y,0},{integer,122}],{x,0}}.
    {test,is_atom,{f,42},[{x,0}]}.
 
{select_val,{x,0},{f,42},{list,[{atom,true},{f,18},{atom,false},{f,19}]}}.
  {label,18}.
    {move,{atom,true},{x,0}}.
    {'%live',1}.
    {jump,{f,21}}.
  {label,19}.
    {move,{atom,false},{x,0}}.
    {'%live',1}.
    {jump,{f,21}}.
  {label,20}.
    {move,{atom,false},{x,0}}.
    {'%live',1}.
  {label,21}.
    {test,is_atom,{f,42},[{x,0}]}.
 
{select_val,{x,0},{f,42},{list,[{atom,false},{f,22},{atom,true},{f,35}]}}.
  {label,22}.
    {bif,'>=',{f,0},[{y,0},{integer,48}],{x,0}}.
    {test,is_atom,{f,42},[{x,0}]}.
 
{select_val,{x,0},{f,42},{list,[{atom,true},{f,23},{atom,false},{f,26}]}}.
  {label,23}.
    {bif,'=<',{f,0},[{y,0},{integer,57}],{x,0}}.
    {test,is_atom,{f,42},[{x,0}]}.
 
{select_val,{x,0},{f,42},{list,[{atom,true},{f,24},{atom,false},{f,25}]}}.
  {label,24}.
    {move,{atom,true},{x,0}}.
    {'%live',1}.
    {jump,{f,27}}.
  {label,25}.
    {move,{atom,false},{x,0}}.
    {'%live',1}.
    {jump,{f,27}}.
  {label,26}.
    {move,{atom,false},{x,0}}.
    {'%live',1}.
  {label,27}.
    {test,is_atom,{f,42},[{x,0}]}.
 
{select_val,{x,0},{f,42},{list,[{atom,false},{f,28},{atom,true},{f,31}]}}.
  {label,28}.
    {bif,'==',{f,0},[{y,0},{integer,95}],{x,0}}.
    {test,is_atom,{f,42},[{x,0}]}.
 
{select_val,{x,0},{f,42},{list,[{atom,true},{f,29},{atom,false},{f,30}]}}.
  {label,29}.
    {move,{atom,true},{x,0}}.
    {'%live',1}.
    {jump,{f,32}}.
  {label,30}.
    {move,{atom,false},{x,0}}.
    {'%live',1}.
    {jump,{f,32}}.
  {label,31}.
    {move,{atom,true},{x,0}}.
    {'%live',1}.
  {label,32}.
    {test,is_atom,{f,42},[{x,0}]}.
 
{select_val,{x,0},{f,42},{list,[{atom,true},{f,33},{atom,false},{f,34}]}}.
  {label,33}.
    {move,{atom,true},{x,0}}.
    {'%live',1}.
    {jump,{f,36}}.
  {label,34}.
    {move,{atom,false},{x,0}}.
    {'%live',1}.
    {jump,{f,36}}.
  {label,35}.
    {move,{atom,true},{x,0}}.
    {'%live',1}.
  {label,36}.
    {test,is_atom,{f,40},[{x,0}]}.
 
{select_val,{x,0},{f,40},{list,[{atom,true},{f,37},{atom,false},{f,38}]}}.
  {label,37}.
    {move,{atom,true},{x,0}}.
    {'%live',1}.
    {deallocate,1}.
    return.
  {label,38}.
    {move,{atom,false},{x,0}}.
    {'%live',1}.
    {deallocate,1}.
    return.
  {label,39}.
    {move,{atom,true},{x,0}}.
    {'%live',1}.
    {deallocate,1}.
    return.
    {'%','Moved code'}.
  {label,40}.
    {test_heap,3,1}.
    {put_tuple,2,{x,1}}.
    {put,{atom,badarg}}.
    {put,{x,0}}.
    {move,{x,1},{x,0}}.
    {'%live',1}.
    {call_ext_last,1,{extfunc,erlang,fault,1},1}.
  {label,41}.
    {test_heap,3,2}.
    {put_tuple,2,{x,0}}.
    {put,{atom,badarg}}.
    {put,{x,1}}.
    {'%live',1}.
    {call_ext,1,{extfunc,erlang,fault,1}}.
  {label,42}.
    {test_heap,3,1}.
    {put_tuple,2,{x,1}}.
    {put,{atom,badarg}}.
    {put,{x,0}}.
    {move,{x,1},{x,0}}.
    {'%live',1}.
    {call_ext,1,{extfunc,erlang,fault,1}}.



More information about the erlang-questions mailing list