Executing boolean expressions on a list

Chris Pressey cpressey@REDACTED
Tue Mar 18 18:11:20 CET 2003


On Mon, 17 Mar 2003 20:04:13 +0100
"Erik Stenman" <Erik.Stenman@REDACTED> wrote:

> 
> Chris Pressey wrote:
> > However, evaluating both sides for type correctness means that
> > 'andalso' isn't really very short-circuiting... i.e. the only semantic
> > difference between 'and' and 'andalso' is when the operands have
> > side-effects, right?
> 
> No, both sides are not evaluated for type correctness,
> but if the rhs needs to be evaluated then the result is checked for type
> correctness.

Sorry, brain fart on my part - I swapped 'andalso' with 'orelse' in my
example.

Also, I committed the cardinal sin of not testing it in the shell:

Eshell V5.2  (abort with ^G)
1> true orelse 5.
true
2> false orelse 5.
** exited: {{badarg,5},[{erl_eval,expr,3}]} **
3> true andalso 5.
** exited: {{badarg,5},[{erl_eval,expr,3}]} **
4> false andalso 5.
false

This is the behaviour I expected.

Thanks,
-Chris



More information about the erlang-questions mailing list