[erlang-questions] eep: multiple patterns
Andras Georgy Bekes
bekesa@REDACTED
Tue May 27 15:03:11 CEST 2008
Hi,
> I agree with Richard O'Keefe that having = as a legal guard
> test is a Good Thing.
>
> - if match succeeds it returns true and binds any unbound variables
> - if match fails, it returns false, i.e. it does generate an error
>
> Then you modify all boolean operations so that if they succeed,
> return true, then any new variables which are bound in them are
> exported, while if they fail, return false, no variables are
> exported.
>
> - This will work for the whole guard as if the guard fails then no
> variables are exported but the clause is not chosen anyway.
> - No problems with not(...) as it will never export variables.
> - Same with other boolean operators, success implies export. This
> makes checking for variable bindings in and after guards relatively
> easy.
>
> As far as I can see there are no problems with this.
I think there is a problem. I think I can express a pattern that's
matching must involve backtracking:
F(A1,A2...) when ({X,_}=A1 or {_,X}=A1) and ({X,_}=A2 ...
So this proposal leads to a language that's too powerful :-(
Just like my very original proposal [1].
The problem with it is discussed [2] through [3].
> Actually thinking about it a bit more if you allow = in guards you
> really don't *need* this multiple pattern feature as you can express
> it as alternate guards.
The "problem" is that this not only makes multiple patterns unnecessary,
but also the whole "Pattern when Guards" stuff (i.e. the part before
the 'when' keyword).
Georgy
References:
[1]:
http://www.erlang.org/pipermail/erlang-questions/2008-March/033718.html
[2]:
http://www.erlang.org/pipermail/erlang-questions/2008-March/033755.html
[3]:
http://www.erlang.org/pipermail/erlang-questions/2008-March/033799.html
More information about the erlang-questions
mailing list