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

Re: Revisiting smart match

Thread Previous | Thread Next
Eirik Berg Hanssen
December 17, 2017 23:55
Re: Revisiting smart match
Message ID:
On Mon, Dec 18, 2017 at 12:15 AM, Zefram <> wrote:

> 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.


> 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?

  upon/uponif?  (Or shorter, on/onif?)

  The "upon" reads well enough.  "do_stuff() upon Int" / "upon (Int) {
do_stuff(); }".

  The shorter "on" is a bit more ambiguous: "do_stuff() on Int" / "on (Int)
{ do_stuff(); }".

  I'm even less enthusiastic about the "if" form.  "do_stuff() uponif Int"
/ uponif (Int) { do_stuff(); }".  It doesn't really read well.

  I'm familiar with Perl6 "so"; hence it is obvious to me it's referring to
a boolean test.  I'm not sure what might be obvious to people unfamiliar
with Perl6, and still read well.

  (Once upon a time, for another discussion on smartmatch, I considered:

  on/onbool/onstr/onnum, or, even shorter: on/onb/ons/onn.

  I eventually suggested case/bcase/scase/ncase instead.  I don't really
recall why.)


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