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

Re: Revisiting smart match

Thread Previous | Thread Next
From:
Rocco Caputo
Date:
December 20, 2017 14:34
Subject:
Re: Revisiting smart match
Message ID:
908216EE-5A51-488A-A484-BDC8EDFF8AAA@pobox.com
> 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';
}

-- 
Rocco Caputo <rcaputo@pobox.com>
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