Search in record list

Kostis Sagonas kostis@REDACTED
Sat Mar 18 16:41:18 CET 2006


Bengt Kleberg wrote:
 >... records are documented as being tuples. it is 
 > neccessary to know this to avoid (among others) the following:
 > 
 > -record( rec, {a} ).
 > 
 > a( T ) when is_tuple(T) -> tuple;
 > a( R ) when is_record(R, rec) -> record.
 > 
 > a( #rec{} ) => tuple

IMO, the compiler, to the extent it can, should warn about redundant
clauses.  Currently, there is a check for redundant clauses, but it
is very rudimentary. It can be improved. For example, the compiler
could warn for the above and also for `similar' functions as e.g.

b(N) when is_number(N) -> number;
b(I) when is_integer(I) -> integer.

Kostis 




More information about the erlang-questions mailing list