[erlang-questions] Reading, Learning, Confused

Thomas Lindgren <>
Mon Jul 21 12:24:28 CEST 2008




--- On Mon, 7/21/08, Richard A. O'Keefe <> wrote:

> Bottom line:
> 	DON'T use 'or' or 'and' ANYWHERE.
> 	DON'T use 'orelse' or 'andalso' in
> guards
> 	but instead stick to ';' and ','.

I normally agree with those recommendations, but with a couple of caveats:

1. You can't nest ';', but you can nest orelse. This can be useful for macros and suchlike.

2. I seem to recall that ';' is implemented by duplicating the clauses, while andalso/orelse is not. If so, andalso/orelse _may_ yield somewhat more compact code.

Both of these properties are basically accidents of history (ie, hacks that have been cast in stone).

Best,
Thomas


      



More information about the erlang-questions mailing list