# Old style vs. new style boolean expressions

Sebastian Strollo <>
Tue Oct 8 22:38:19 CEST 2002

James Hague <> writes:

> > I don't think this make much of a difference most of the 
> > time, and even if it
> > increases the size noticeably - does it matter ?
> It only matters to people who obsessively peek behind the scenes :)

For those that are curious there is always the 'S' option to the
compiler - it outputs the beam "assembly" into a "module.S" file. So
for example the following:


    f1(N) when N >= $A, N =< $Z -> true;
    f1(N) when N >= $a, N =< $z -> true;
    f1(N) when N >= $0, N =< $9 -> true;
    f1($_) -> true;
    f1(_) -> false.

    f2(N) ->
            ((N >= $A) and (N =< $Z)) or
            ((N >= $a) and (N =< $z)) or
            ((N >= $0) and (N =< $9)) or
            (N == $_).

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

    1> compile:file(f, ['S']).

Now you will have a file called f.S, and looking at f1 and f2 you will
see that it generates very different code indeed...

    {function, f1, 1, 2}.
    {function, f2, 1, 10}.



More information about the erlang-questions mailing list