Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What parts of given/when are experimental?

Has the entire "switch" feature become experimental? Are there parts of it I can rely on using without future versions of Perl breaking my code? In general, what is the policy toward changing stable features to experimental?

Background

use feature "switch" has been in Perl since 5.10. From 5.10 to 5.14, perlsyn seems to indicate that this is a stable, supported feature.

Starting with 5.16, however, perlsyn begins to call it "an experimental switch feature" and gets a lot more confusing about what's considered experimental.

Parts of the documentation seem to indicate everything about the feature is experimental:

Under the "switch" feature, Perl gains the experimental keywords given, when, default, continue, and break.

There's even an entire section about the Experimental Details on given and when.

However, perlsyn also says that "The foreach is the non-experimental way to set a topicalizer" and gives an example that seems to imply that foreach/when is not experimental.

As far as I can tell, the "experimental" language came from commit c2f1e22 which references RT #90926 which still doesn't give much context, even when paired with RT# 90906.

like image 707
daxelrod Avatar asked Dec 14 '12 19:12

daxelrod


1 Answers

Has the entire "switch" feature become experimental?

No. It has always been.

Upd: Oh wow, maybe I'm wrong. I can't find a mention of that in 5.10.0 or .1. Maybe it wasn't? Or maybe they forgot to note it? Either way, it seems they messed up worse than I thought if so! But based on what I've seen since, I think the lesson was learned. (e.g. I still think values $ref is a bad idea, but at least it was marked experimental from day 1.)

Are there parts of it I can rely on using without future versions of Perl breaking my code?

Technically, no, although the devs are always careful when it comes to backwards compatibility.

In general, what is the policy toward changing stable features to experimental?

I don't see that ever happening. The deprecation process would be used instead.


Changes so far:

  • given is changing from creating a lexical $_ to localising $_ like foreach loops in 5.18 (or did it already happen in 5.16?).

  • 5.10.1 saw some big changes in smart-matching*. Don't use (smart-matching in) 5.10.0.

Possible future changes:

  • The behaviour of smart-matching* is still a hot topic.

* — True, this is a feature distinct from given-when, but it's the same or closely related in most people's minds.

like image 120
ikegami Avatar answered Sep 27 '22 15:09

ikegami