Executing boolean expressions on a list

Chris Pressey cpressey@REDACTED
Mon Mar 17 19:37:51 CET 2003


On 17 Mar 2003 16:28:20 +0100
Bjorn Gustavsson <bjorn@REDACTED> wrote:

> Richard Carlsson <richardc@REDACTED> writes:
> 
> > On Sat, 15 Mar 2003, Pierpaolo BERNARDI wrote:
> > 
> > Well, this is what I also said when we implemented it, but the OTP
> > guys were not convinced, and preferred to have the check there. But
> > perhaps your complaints will be more influential. Björn, are you
> > reading this?  :-)
> > 
> 
> I not just me. When asking people in the OTP group, nobody liked the
> idea of not checking the right-hand side of 'andalso' and 'orelse'. The
> change would not be consistent with how 'and' and 'or' work.
> 
> /Bjorn

I can see why the thought of "true andalso 5" succeeding without an error
would be disturbing to the OTP team.

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?

A quick grep through the OTP sources doesn't reveal any 'andalso's or
'orelse's with obviously side-effectful operands.  (which is probably a
*good* thing)

So, it hadn't occurred to me before this thread, but this strikes me as a
lot less useful than 'andalso' in a strongly-typed language.  Personally I
could live with "true andalso 5" succeeding; I could also live with plain
'and' and 'or' having short-circuiting semantics.  Of course, whatever the
OTP team decides, I'll manage :)

-Chris



More information about the erlang-questions mailing list