Match Specifications

Francesco Cesarini francesco@REDACTED
Wed Oct 24 19:10:17 CEST 2001


I tried to be diplomatic, but as there is local backing, I guess I can openly
say that, even if *extremely* powerful, they are pretty dam ugly . And believe
me when I say that teaching them to testers and support engineers is not a
pretty task either. They are the ones out in the field who need match
specifications the most, but at the same time, among Erlang users, they are also
the ones with the least software knowledge/experience. So far, since they have
gotten documented, I have unfortunately only seen master programmers dare use
them (And they can be counted on the fingers of one hand).

A prettier, more Erlang like syntax would be very welcome, and open up Match
Specifications to less experienced programmers. I am unsure if parts of it can
be handled in the pre-processor, however, as just like records, it would not be
possible to use them from the shell.

Cheers,
Francesco

Sean Hinde wrote:

> > 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
> ets:select.
>
> something like:
>
> A="an",
> M = matchfun({tab, "se" ++ A, B}) when is_integer(B) -> '$_';
>             ({tab, "se" ++ A, B}) -> B
>     end,
> 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?
>
> Sean
>
> NOTICE AND DISCLAIMER:
> 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.

--
http://www.erlang-consulting.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: francesco.vcf
Type: text/x-vcard
Size: 352 bytes
Desc: Card for Francesco Cesarini
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20011024/b5ece017/attachment.vcf>


More information about the erlang-questions mailing list