[erlang-questions] Order of evaluation of guards

Anthony Ramine n.oxyde@REDACTED
Mon Jan 5 16:00:08 CET 2015


Le 5 janv. 2015 à 15:39, Robert Virding <rvirding@REDACTED> a écrit :

> That the ',' is not short circuit is an implementation detail, and the wrong choice at that. Originally guards were evaluated from left-to-right and as soon as a test failed the guard failed, the ',' was short circuiting. This was also consistent with ';' alternate guards which was also left-to-right and short-circuiting, as soon as one of the guard sequences succeeded the whole guard succeeded.
> 
> I don't know when ',' became strict but it was never intended to be that. It should behave the same as 'andalso' and not as 'and'.

',', 'and' and 'andalso' all compile to short-circuiting code, but the 'andalso' code is more convoluted than it should:

https://gist.github.com/nox/655450660d148095071c


More information about the erlang-questions mailing list