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

Re: Revisiting smart match

Thread Previous | Thread Next
From:
Craig A. Berry
Date:
December 18, 2017 22:51
Subject:
Re: Revisiting smart match
Message ID:
CA+vYcVz41Me214YNPdHqG3Kj0u330v4x-C9ToGyFcSzQtiRCZw@mail.gmail.com
On Sun, Dec 17, 2017 at 8:38 PM, Zefram <zefram@fysh.org> wrote:
> Eirik Berg Hanssen wrote:
>>  upon/uponif?  (Or shorter, on/onif?)
>
> "upon" shows some promise.  It reads well, and could serve as either of
> the keywords.  But "uponif" is poor.  "on" also reads well on its own,
> but has the same issue with "onif".  These also need to be checked
> against Moose; "on" is fairly likely to be used by a popular CPAN module.
>
>>  I'm even less enthusiastic about the "if" form.  "do_stuff() uponif Int"
>>/ uponif (Int) { do_stuff(); }".  It doesn't really read well.
>
> "Int" isn't a realistic condition.  It would be "do_stuff() uponif $a ==
> $b", which also reads poorly.
>
> "upon" combines a bit better with "so": "do_stuff() uponso $a == $b".
> But that's still not great.  Generally, if we want something reading
> well as English, it's going to be easier to add "so" than to add "if".

Here's a bit more (very belated) paint to fling at the bikeshed.

whereas($input) {
        whenever ($_ eq "string") { die "A" }
        whenever ($_ == 90210)    { die "B" }
        whenas ($matcher)      { die "C" }
    }

These are all perfectly natural English words combined from very small
and simple English words.  Try it in English: Whereas I am a Perl
programmer, whenever I write Python, I miss the curly braces, and
whenever I write Java, I dread the boilerplate, and whenas I have to
write anything in XPATH, XQuery, or XSLT, I get a major headache.  For
less naturalness but more precision, replace whenever/whenas with
whenis/whenlike.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About