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

Re: Revisiting smart match

Thread Previous | Thread Next
From:
H.Merijn Brand
Date:
December 18, 2017 07:26
Subject:
Re: Revisiting smart match
Message ID:
20171218082519.29cb8362@pc09.procura.nl
On Sun, 17 Dec 2017 14:39:28 -0500, Ricardo Signes
<perl.p5p@rjbs.manxome.org> wrote:

> * Zefram <zefram@fysh.org> [2017-12-05T19:20:49]
> > I wrote:  
> > >I have not yet introduced a short syntax for "when" with smartmatch,
> > >nor renamed "when".  
> > 
> > I have now done these, on the zefram/dumb_match branch.  The version of
> > "when" that uses its argument as a truth value is now called "whereso",
> > and the version that smartmatches is called "whereis".
> > [...]
> > The "so" and "is" particles make it pretty obvious which has which semantics.  

Probably it does for native English speakers, but I personally find
these confusing. I said to someone earlier: "If this sticks, I'll
probably have to look it up in the manual every time I use it, if at
all". That to me also shows the weakness. If I don't know what to use
when I *write* it, it must be even harder to read/maintain it to people
that do not use or have never used it at all.

switch/case/when was easy to remember

> I realize it has been nearly two weeks since this post, and I won't push the
> issue, but I object to these names.  In particular, I find that last quoted
> sentence impossible to agree with.
> 
> This is going to lead to confusion for learners, and native English speaking
> won't be the issue.  The issue will be that the two terms have no real clear
> distinction.
> 
> The semantics are now so much better that having such unclear keywords would be
> a shame.  I suggest something that includes "if" or "true" for the if-like
> form, and/or something that includes "match" for the matching form.
> 
>   ifcase  (...) { ... }
>   caseif  (...) { ... }
>   whenif  (...) { ... }
>   case if ( ... ) { ... }
> 
>   case    (...) { ... }
>   when    (...) { ... }
>   casematch (...) { ... }
>   testcase  (...) { ... }
>   case when (...) { ... }
> 
> That's the last I'll post on this unsolicited.

-- 
H.Merijn Brand  http://tux.nl   Perl Monger  http://amsterdam.pm.org/
using perl5.00307 .. 5.27   porting perl5 on HP-UX, AIX, and openSUSE
http://mirrors.develooper.com/hpux/        http://www.test-smoke.org/
http://qa.perl.org   http://www.goldmark.org/jeff/stupid-disclaimers/

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