Enhanced type guard syntax]

Vlad Dumitrescu <>
Thu Sep 18 21:13:47 CEST 2003


Hi,

> isOne( X )    when X == 1; X == "one"    ->    true;
> isOne( X )    ->  false.

Why not

isOne(1) -> true;
isOne("one") ->true;
    % or maybe even
    % isOne("one")->isOne(1);
isOne(_) ->false.

? Looks simpler to me ;-)

> Most of the languages are either STRONGLY or weakly typed.
> Erlang can be both and more -- it can match patterns that can
> be specified/grouped through their semantics, not only syntax.
> For example, when we say ONE, we can write it as "1" or
> "one" -- it wouldn't change the meaning, right?

In your example, the guards X==1 and X=="one" are not typing guards, but
matching ones. Thus according to the proposal, they would remain valid.

regards,
Vlad



More information about the erlang-questions mailing list