Front page | perl.perl5.porters |
Postings from June 2022
Re: disabling smartmatch and when()?
Thread Previous
|
Thread Next
From:
Ricardo Signes
Date:
June 25, 2022 15:18
Subject:
Re: disabling smartmatch and when()?
Message ID:
d86fcc10-b990-497d-a044-38a09d704bc8@www.fastmail.com
On Sat, Jun 25, 2022, at 08:09, Tom Molesworth wrote:
> On Fri, 24 Jun 2022 at 22:07, Ricardo Signes <perl.p5p@rjbs.manxome.org> wrote:
>> __
>> I'm all for having a better replacement, but I continue to strongly oppose the idea that we *need* one to remove the old thing.
>
> Do we _need_ to remove smartmatch before that happens?
No. We can do them in either order.
> What development is currently blocked by having it in place? We don't like the way it works, sure - but in that case why are other frequently-misused constructs such as `each %hash` still in core?
"each" has been in Perl since at least v3. (I didn't look further back, I just grabbed my pink camel.) The documentation mentions it's a bit fragile, but that's about it. (Oral tradition, of course, is that it's A Big Mess.)
On the other hand, for nine years, ~~ has issued a warning described as:
This is currently an experimental feature, and its details are subject to change in future releases of Perl. Particularly, its current behavior is noticed for being unnecessarily complex and unintuitive, and is very likely to be overhauled.
So, why is smartmatch more available for chopping than each? Because we've been saying so for nearly a decade.
Is it worth whatever kerfuffle will be caused by removing it? I don't know yet. Or, what might need to be done to further make it palatable, if possible? Improve the message emitted, etc.
> > The result of the above is that half of CPAN relies on smartmatch:
> >
> > https://grep.cpanauthors.org/search?q=%7E%7E+OR+%22given+%28%22+OR+%22given%28%22
Could somebody elaborate on how we get from that link to "half of CPAN"?
>> A replacement would be nice, if it's good, but it doesn't need to exist before we take the old thing out.
>
> I would suggest that it does.
>
> We went from "Perl does not have `switch`/`case`, just use `if`", to "Perl has something better than `switch`/`case`, everyone use that instead", and now it's back to "just use if, we have no realistic plans for improving this".
The second state existed only very briefly in the mouths of p5p.
* Twenty years: Perl doesn't have a case statement.
* One year: Perl has a useful case statement alternative!
* Four years, *tops*: Okay, that was bad, but we made it better.
* Nine years: Okay, it's a mess, we maybe going to radically change or ditch it so don't rely on it.
--
rjbs
Thread Previous
|
Thread Next