[erlang-questions] : eep: multiple patterns

Raimo Niskanen raimo+erlang-questions@REDACTED
Thu May 15 11:00:36 CEST 2008


On Thu, May 15, 2008 at 01:27:55PM +1200, Richard A. O'Keefe wrote:
> I feel that this proposal is a step in the wrong direction,
> and has "hack" written all over it.
> 
:
> 
> So instead of adding a new "crippled-bind" called ~=,
> I suggest that it would be better to allow
> Pattern = Expression as a guard.
> 
> What about the intended uses of ~= where the fact that
> it does not bind variables is important?  Why then,
> just restrict the corresponding = to not bind variables.
> {foo,_,27} = hd(X) would have the same effect in a guard
> as {foo,_,27} ~= hd(X) would have, so if we allowed =,
> there would be no point in having ~= as well, while if
> we had ~= we would still be left lamenting the
> inexplicable prohibition on =.
> 
> Do I need to mention that the similarity between = and
> ~= would lead to errors when one was used but the other
> intended?  No, I thought not.  ~= is something we are
> better off without.  But its use in guards _is_ something
> we could do with, only the existing = would be far better.
> 
> That's enough for one message, I think.
> 

So far I agree.

> Maybe not.
> 
> I don't like vague suggestions that
> "It is rather common to check the value of an expression with a
>      case expression and do the same actions in some of the cases."
> I want to see *actual cases*.

But on this one I have experienced so many *actual cases*
myself to accept it as an inconveniance. A solution
to the multiple patterns to one branch problem would
be convenient, indeed.

> 
> Oh, and did I point out that abstract patterns can solve the
> "multiple patterns" problem neatly and clearly?
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB



More information about the erlang-questions mailing list