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

Re: Revisiting smart match

Thread Previous | Thread Next
From:
Dan Book
Date:
December 26, 2017 20:49
Subject:
Re: Revisiting smart match
Message ID:
CABMkAVWdsguscSkphaAL-A7AemK1WEREBGiFPR6oXTA9TjMFdA@mail.gmail.com
On Wed, Dec 20, 2017 at 9:34 AM, Rocco Caputo <rcaputo@pobox.com> wrote:

> On Dec 20, 2017, at 04:01, D Perrett <perrettdl@googlemail.com> wrote:
>
> To me the syntax which makes sense is:
>
> given SUBJECT {
>   such that CONDITION BLOCK
>   such as MATCHER BLOCK
> }
>
>
> As the problem was presented to me, the postfix forms are required and
> must use the same keywords as the prefix forms.
>
> If we could ignore postfix, I'd suggest:
>
> when SUBJECT {
>   matches MATCHER { ... }
>   passes CONDITION { ... }
> }
>
> But for now, it fails because the required postfix forms read poorly:
>
> when SUBJECT {
>   do { ... } matches MATCHER;
>   do { ... } passes CONDITION;
> }
>
> In particular, the transitive verbs are so tightly coupled to do{} in the
> reader's mind that the real subject gets lost.  Even when the $_ pronoun is
> used.  This could be implemented, but it's nonsense to humans:
>
> given SUBJECT {
>   do { ... } passes $_->foo eq 'bar';
> }
>
>
Since the hardest part of coming up with applicable terms is the postfix
requirement, here's another possibility: One or both terms could have an
alias (like for and foreach) that is interchangeable but reads better in
the postfix form. For example 'matches' and 'ifmatches' or 'whenmatches'.
Not proposing that specifically, but maybe someone has better ideas with
that in mind.

-Dan

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