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

Re: Deprecation of smartmatch

Thread Previous | Thread Next
From:
Martijn Lievaart
Date:
December 4, 2022 10:20
Subject:
Re: Deprecation of smartmatch
Message ID:
0f132139-916d-bd45-c227-f6fe694e4711@rtij.nl
Op 02-12-2022 om 18:38 schreef Paul "LeoNerd" Evans:
>
> I believe that, between them, this set of ideas and syntax could be a
> useful addition to the Perl language, as a much more predictable and
> controllable alternative to smartmatch.
>

Wouldn't this syntax be worthwhile to be generalised, so it can be used 
for user defined subs as well?


F.i.

sub my_in($needle :use($op), @haystack)

{

     for (@haystack) {

         return $_ if $_ :$op $needle;

}


Note this is a brainstorm idea, the above has some obvious problems. 
First there is a syntax problem, as written it clashes with ternaries. 
Secondly, different operations would need $needle to be either on the 
LHS or RHS, but I already mailed about that in another separate mail, 
better to discuss that problem there first.


Obviously it would be great if this would be somewhere in the future. I 
bring it up now because if we want it, it might have effect on the 
syntax of the currently proposed 'in'.


HTH,

M4




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