Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Endorsement from committer to submit TPF Grant Application to add given/when to Switch.pm

by ait (Hermit)
on Apr 01, 2024 at 13:47 UTC ( [id://11158622]=perlquestion: print w/replies, xml ) Need Help??

ait has asked for the wisdom of the Perl Monks concerning the following question:

Hi there, fellow monks!

If a committer is reading this, I would like to submit a grant not for myself for for Switch.pm author or any other volunteer to add given/when to Switch.pm

It's ironic that such a widely used module (Switch.pm) actually recommended for people to migrate to given/when and now Perl core decided to deprecate starting in 5.38

Adding a simplified, mostly compatible given/when in Switch.pm would save a lot of people a lot of trouble. I can suspect that most people just used it as a fancy if/elsif/else and did not use a lot of the smart matching capabilities, although I could be wrong. In any case, I think that in TIMTOWTDI tradition, we should add given/when to Switch.pm and allow most people to simply replace use feature 'switch' by use Switch

I am confident a committer will pick up this thread and endorse this proposal in my TPF Grant application, so I will just link this tread ;-)

TIA
Alex

  • Comment on Endorsement from committer to submit TPF Grant Application to add given/when to Switch.pm

Replies are listed 'Best First'.
Re: Endorsement from committer to submit TPF Grant Application to add given/when to Switch.pm
by hippo (Archbishop) on Apr 01, 2024 at 14:58 UTC
    to add given/when to Switch.pm

    No need - it's already there.


    🦛

      wut?

      LOL. Never noticed use Switch 'Perl6'

      I guess the only change required to Switch.pm then is to stop recommending to use the feature 'switch' ;-)

      Thank you for that! I guess this covers what I was suggesting to add to Switch.pm so this discussion is no longer needed.Maybe I should RTFM better next time.

      Best,
      --
      Alex

        So I'm the only one who thought this post was an April Fool's day gag?
Re: Endorsement from committer to submit TPF Grant Application to add given/when to Switch.pm
by Anonymous Monk on Apr 02, 2024 at 13:04 UTC
    April Fools??? Switch PM hasn't been in the core for like 13 years and was removed because it's buggy.
    ... would save a lot of people a lot of trouble.
    No. Source filters cause much pain.

    Switch::Plain?

    or just if/elsif...

      Buggy? Wasn't it because Nintendo claimed name infringement?
Re: Endorsement from committer to submit TPF Grant Application to add given/when to Switch.pm
by TheDamian (Vicar) on Apr 08, 2024 at 23:55 UTC
    As it so happens, I'm already on this.

    Watch for my 2024 TPC talk in June. ;-)
Re: Endorsement from committer to submit TPF Grant Application to add given/when to Switch.pm
by ikegami (Patriarch) on Apr 01, 2024 at 14:16 UTC

    The problem with given/when is that the design is broken. How do you plan to modify it to address this?

      I don't have an answer for this at the moment which is why I proposed 40 hours of work to analyze the current implementation, look at the Raku implementation and then come up with simplified design that covers most of the cases people have been using given/when for in Perl 5

      Also, in the grant proposal I stated that the most qualified person for this is probably Switch.pm author, but perhaps some other qualified volunteer is able and willing to do it.

      I would volunteer but not before fully understanding the flaws of the current design, perhaps something we can hash out in this thread at least. I have personally used given/when in it's simple full match form, easily replaceable by if ($foo eq 'bar') elsif, elsif, else. But maybe a lot of people used the advanced smart matching which is where I believe the current implementation is flawed. But I am not sure, because I never used any of these advanced features of given/when and I suspect most people didn't either.

      Maybe we should also hold a poll to see if people used given/when for more than just a simple matching switch.

        I asked because it sounded like you wanted a drop in replacement for given/when ("allow most people to simply replace use feature 'switch' by use Switch").

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11158622]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2025-06-18 18:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.