Match Specifications

Sean Hinde Sean.Hinde@REDACTED
Wed Oct 24 18:19:21 CEST 2001

> Francesco Cesarini wrote:
> > 
> > Hi!
> > I got stuck with match specifications

Sorry to misquote :) I don't think anyone really thinks that the pattern
match syntax is all that elegant though.

Maybe there is scope for something cleaner for at least the subset used in

something like:

M = matchfun({tab, "se" ++ A, B}) when is_integer(B) -> '$_';
            ({tab, "se" ++ A, B}) -> B
ets:select(tab, M).

instead of
M = [{{tab, "se" ++ A, '$1'}, [{is_integer, '$1'}], ['$_']},
     {{tab, "se" ++ A, '$2'}, [], ['$2']}],
ets:select(tab, M).

This example isn't too bad but more complex examples get seriously
unreadable to anyone not well up on syntax trees (inluding me).

We could get rid of '$1', '$2' etc by letting the compiler turn unbound
variables into '$1' etc internally. We'd maybe keep '$_' and '$$' as nice
shortcuts for complete results.

Thoughts anyone? Maybe a clever precompiler hack by someone versed in the
ways of such things could deliver this?


This email (including attachments) is confidential.  If you have received
this email in error please notify the sender immediately and delete this
email from your system without copying or disseminating it or placing any
reliance upon its contents.  We cannot accept liability for any breaches of
confidence arising through use of email.  Any opinions expressed in this
email (including attachments) are those of the author and do not necessarily
reflect our opinions.  We will not accept responsibility for any commitments
made by our employees outside the scope of our business.  We do not warrant
the accuracy or completeness of such information.

More information about the erlang-questions mailing list