[erlang-questions] erlang *****

Andras Georgy Bekes bekesa@REDACTED
Mon Mar 17 16:02:31 CET 2008

> But now consider 
> 	f({X,_}\/{_,X},
> 	  {Y,X}\/{X,Y},
> 	  ...
> 	  {Z,W}\/{W,Z}
> 	)
So matching this pattern must involve backtracking. Awww.

> You could hack around this by requiring that if a head variable is
> bound in a disjunctive pattern it is not matched by any other head
> pattern.
The problem does exist in a single pattern:

We could of course generalise the above restriction, but it doesn't make 
it tolerable.

But what are the real problems with the search for the right match with 
backtracking? If the programmer has written that silly pattern, he/she 
should be aware that it might not be very fast. Are there consequences 
other than the match being slow?

> I note that my abstract pattern proposal *already* gives you
> disjunctive patterns, BUT in such a way that the disjunctions can't
> interact like this.
Could you give some reference?
I've searched for "abstract pattern" in the archives and found a few 
mail, but not your paper.


More information about the erlang-questions mailing list