Why no is_octet(N) guard?

Joe Armstrong (AL/EAB) joe.armstrong@REDACTED
Thu Mar 10 16:59:07 CET 2005


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? 



This is what macros are for

	-define(DIGIT(X), X >= $0, X =< $9).

Then use it like this:

	foo(X) when ?DIGIT(X) ->
	   ...

  /Joe


> -----Original Message-----
> From: peter [mailto:erlang@REDACTED]
> Sent: den 10 mars 2005 10:51
> To: erlang-questions@REDACTED
> Subject: Why no is_octet(N) guard?
> 
> 
> 
> Now you need 3 guards to test if an argument is_octet:
> 
> foo(N) when is_integer(N), 0=<N, N=<255 -> do_stuff;
> foo(_) ->  do_other_stuff.
> 
> it would have been much nicer if this chould be written with 
> a is_octet() guard.
> 
> foo(N) when is_octet(N) -> do_stuff;
> foo(_) ->   do_other_stuff.
> 
> I find the need of the is_octet guard quite common, so why 
> not supply one extra
> guard for this soon?Peter Lund
> _________________________________________________________
> Sent using Mail2Forum (http://m2f.sourceforge.net)
> 



More information about the erlang-questions mailing list