Enhanced type guard syntax]
Richard A. O'Keefe
Mon Sep 22 08:13:08 CEST 2003
Concerning the examples:
foo(X == 2 * Y)
% foo(X, Y) when X == 2*Y
foo(X > Y)
% foo(X, Y) when X > Y
am I the only one who is bothered (to put it politely) that the
"improved" versions _look_ as if they have one argument, but are
supposedly equivalent to functions with _two_ arguments, and that
there's no obvious way to tell which argument is which?
For some reason, Haskell programmers don't seem to might writing
foo x y | x == 2*y =
foo x y | x < y =
I also don't think it's any more difficult to read, once you
unlearn the arbitrary convention that "comma seperates arguments".
It may be arbitrary, but so are all human communication conventions,
and this one has been going strong in programming languages for 50 years.
"As a language design idea in its own right", I very much dislike a
notation where I can't tell which argument is which.
Now let's consider
f([X|_], [Y|_]) when X < Y -> ...
how do you write _that_ without commas? Good ideas (like abstract patterns)
work in general cases.
More information about the erlang-questions