length() in guards

Bengt Kleberg Bengt.Kleberg@REDACTED
Mon Sep 29 09:41:16 CEST 2003


Richard A. O'Keefe wrote:
> One of the perennial questions about Erlang is "can't we generalise
> guards to allow any expression?"  The standard response is that the
> guard tests and expressions are supposed to have certain properties.
> And the standard retort to that is that length/1 does't have them.
> 
> A tiny restriction would tame length/1 in guards.
> The restriction is
>     "a call to length/1 may appear in a guard only as an entire
>      operand of a comparison (==, /=, <, >=, >, <=, =:=, -/=)
>      in which the other operand is not a call to length/1".
> 
...deleted

 > What do people think?

what about:

is_length_equal( Var, Length )
is_length_greater( Var, Length )
is_length_less( Var, Length )

this would make it easier to remember, imho.


bengt




More information about the erlang-questions mailing list