develooper Front page | perl.perl5.porters | Postings from December 2017

Re: Revisiting smart match

Thread Previous | Thread Next
December 17, 2017 23:15
Re: Revisiting smart match
Message ID:
Ricardo Signes wrote:
>The semantics are now so much better that having such unclear keywords would be
>a shame.

The keywords are certainly still up for debate, and I wish this
dissatisfaction had been registered earlier.  I'd be interested in
better keywords if they can be found.

Although I like the "so" particle for truth values, I could agree with an
"if" particle instead.  Using "match" to contrast "if" runs into Huffan
problems: if anything we want the matching version to be shorter.

Using "when" has multiple problems.  Using it on its own, for either
semantic, would mean that existing code using "when" with the old
maybe-match rules would see some significant silent change in behaviour;
it seems better to break all those uses.  Apart from that, "when"
seems like a synonym for "if".  It's not adequately distinguished from
"if", and would thus be especially confusing to use on its own for the
smartmatching semantic.  Its temporal connotation also makes it seem
especially related to "while".

Of your specific suggestions, there is a pair that stands out as
relatively agreeable: "case" for smartmatching and "caseif" for truth
value.  This has the very distinctive "case" as the particle identifying
the implicit-next semantic, an "if" particle distinguishing between
matching and truth value, and the Huffman coding the right way round
between them.  This seems fine for the keywords in their prefix form.
However, they read very poorly in postfix form: "do_stuff() case Int".

Much of the difficulty in choosing keywords here comes from trying to
get them to read naturally as English.  That's a Perlish value, and
especially important in the postfix form.  While "case" is suitably
distinctive and has appropriate programming connotations, it doesn't
read as an English modifier at all.

Got any more ideas?


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About