[eeps] EEP XXX: Pattern-test operator
Erik Søe Sørensen
Fri Apr 27 22:13:10 CEST 2012
Den 27. apr. 2012 21.12 skrev David Mercer <>:
> On Apr 23, 2012, at 19:06, "Richard O'Keefe" <> wrote:
> > On 24/04/2012, at 10:52 AM, Robert Virding wrote:
> >> I have missed one part of the discussion here and that is about ?=:
> >> why use ?= in a guard and not =, and what does ?= mean outside a
> >> guard?
> . . .
> > The problem now is that EITHER
> > f(X) when X =  -> ...
> >> f()
> > fails (because the match X =  succeeds but has value  which is
> > taken as false in a guard) OR the behaviour of = in a guard is
> > inconsistent with its behaviour in an expression.
Funny thing: I don't even know what kind of expressions the list
comprehension guards are, and thus which of the rules would apply. As far
as I can tell with a browser but not an Erlang shell within reach, LC
filters can be all kinds of expression (i.e. not restricted to guard
expressions), although they appear in a guard-ish context. I think that's a
very good reason not to let the meaning of '=' depend on the context.
> Why not
> > f(X = ) -> …
> > f(X) when X =:=  -> …
Because Richard's example wasn't an illustration of "why do we need this
feature?", but of "why won't this syntax work?".
This particular example can, as you point out, be expressed quite well
using current Erlang.
The main features of the operator candidate are pattern matching in guards,
and bindings from guards.
I hope this clarifies things.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the eeps