[erlang-questions] illegal guard expression with lists:nth
Thu Jun 11 11:53:10 CEST 2009
On 11/giu/09, at 11:50, Pierpaolo Bernardi wrote:
> You cannot use any function you want in a guard, but only a few BIFs.
> length/1 is one of them, lists:nth/2 is not.
> Check the manual for "guard sequences".
On 11/giu/09, at 11:49, Robert Virding wrote:
> Sort of. :-) The reason is that if only allows guard tests and while
> length/1 is a valid guard tests no calls to erlang functions are. So
> if is really:
> if <guard test> -> ...;
> <guard test> -> ...;
> That is why an else case is usually written as true -> ... as true
> is a guard test which always succeeds.
i do understand the point, and pierpaolo i know about guard sequences.
let's say mine is kind of a 'feature request', since 'case'
expressions do allow this and 'if' ones, not. therefore i was
questioning whether i'm missing a point why this shouldn't be done in
More information about the erlang-questions