Why no is_octet(N) guard?

Kostis Sagonas kostis@REDACTED
Thu Mar 10 22:03:46 CET 2005

Joe Armstrong wrote:

 > I disagree - please not more special purpose guards when a general mechanism  > will do and why just is_octet? what about is_digit, is_alpha_numberic,
 > is_ascii, is_unicode, is_bananna? 

All this discussion is somehow unnecessary.  Erlang at some point
*should* be extended with the ability to allow arbitrary user-defined
guards.  Conservatively checking whether a (module-local for a start)
function is side-effect free is not exactly rocket science... 

In any case, this is what I really want to reply to with my post:

 > This is what macros are for
 >  -define(DIGIT(X), X >= $0, X =< $9).

Even disregarding for a moment that macros are not what a language
should be forcing users to rely upon -- and that the Erlang preprocessor
is not really the most well-though and flexible macro expansion system
around -- the whole discussion about the is_string/1 guard really shows
a limitation and the brain-damage of the is_list/1 guard.

If the is_list/1 guard were really testing that something is a proper
list, then one could simply write the is_string/1 guard as a macro with
the currently available Erlang guards.  Alas, it is just a very
misleading name for is_cons_or_nil/1.  IMO, this sucks.


More information about the erlang-questions mailing list