http://www.perlmonks.org?node_id=1052119

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

Greetings,

Today I started using perl 5.18 with my code and I was not pleased to see lots of warning saying that when is experimental.

While perldelta teaches how to disable the warnings, it also says:

Simply suppress the warning if you want to use the feature, but know that in doing so you are taking the risk of using an experimental feature which may change or be removed in a future Perl version

I wondering if it is not a better idea to go back using labeled blocks to simulate the functionality of given and when. I also saw that smart matching has problem on it's own and I already had some issues with it.

What do you recommend for this king of situation for long term code?

Thanks,

Alceu Rodrigues de Freitas Junior
---------------------------------
"You have enemies? Good. That means you've stood up for something, sometime in your life." - Sir Winston Churchill

Replies are listed 'Best First'.
Re: Is a good or bad idead to "use feature 'switch'"?
by davido (Cardinal) on Sep 03, 2013 at 15:41 UTC

    given/when, and smartmatch are syntactic sugar for other constructs. You named one alternative, and there are others including dispatch tables with coderefs. given/when/smartmatch weren't re-labeled "experimental" only because they will probably change. The re-labeling is also because their current condition is a little broken, and a little odd, which prevents them from being fully embraced. I'd say that for the time being there are several good reasons to avoid them.


    Dave

Re: Is a good or bad idead to "use feature 'switch'"?
by tobyink (Canon) on Sep 03, 2013 at 14:56 UTC

    Personally I've been moving from smartmatch to match::simple, which provides a like-smartmatch-but-sane match() function.

    I'm also working on a counterpart switch statement, but that's likely to require Perl 5.14+. (Update: Switcheroo.)

    use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name
Re: Is a good or bad idead to "use feature 'switch'"?
by daxim (Curate) on Sep 03, 2013 at 14:57 UTC
    It is okay to use the feature and disable the warning if you are prepared to change the code when it becomes necessary. That's what the risk means.
Re: Is a good or bad idead to "use feature 'switch'"?
by sundialsvc4 (Abbot) on Sep 03, 2013 at 20:07 UTC

    It would be very helpful to all of us, I think, if you would tell us a bit more about “your code.”   You say that you “use labeled blocks ot simulate ...” but can you please show us a brief example of what you are doing?   When you “had issues with smart matching,” can you please elaborate?

    FYI, I personally avoid “experimental” features like the plague, especially when, as in this case, “There’s (Already) More Than One Way To Do It,™” namely, “the way that this sort of thing has been done for years.”   If The Implementors (Ommmmm....) have not decided yet what The Future Course Of The Entire Perl World™ will Be,™ then I personally am not keen on guessing wrong.   Frankly, I’d rather not guess.   I can wait, and/or do without the Goodness, because I already know how (else...) to do switch, in code that won’t come back to bite my warranty.   But, Your Mileage May Vary.™

      Now you're throwing trademark symbols randomly into your posts? What's next, are you going to vomit a whole box of Lucky Charms out of your keyboard?