Item Description: Switch - A switch statement for Perl, do not use if you can use given/when
Review Synopsis: The Switch module should be marked deprecated.
My thesis is that the Switch module should be marked deprecated.
One will find that many Perl Monks advise fellow programmers not to use the Switch module in any Perl program that even hints at eventually becoming production status source code. (The evidence is in the paragraphs below.)
This proposed deprecation marking is for the benefit of beginning and intermediate Perl programmers.
In most cases, advanced Perl programmers know better than to use it in serious source code, because many of them spend time at Perl Monks , stackoverflow, or in IRC channels devoted to Perl programming and see the (sad) results of beginning and intermediate Perl programmers being lured into using this module.
% corelist Switch Data for 2016-06-20 Switch was first released with perl v5.7.3, deprecated (will be CPAN-o +nly) in v5.11.0 and removed from v5.13.1
One more administrative detail to deal with here: This review is part of a larger project to deprecate the Switch module. For details, please read this post describing a step by step recipe for deprecating this module (or any module) by hippo.
Below, I offer some hyperlinks that (I hope) will convince the reader that the Switch module should be deprecated.
- The thread entitled Switch depreciated?
Summary: A Perl programmer is confused because Perl::Critic complains that the Switch module is deprecated.
- The thread entitled Perl Switch Errors on certain version
Summary: A Perl programmer seeks advice regarding an error message due to using the Switch module. If one reads through the replies, one will eventually see one where Corion directs us to a post by Damian Conway that categorizes Damian's modules. Of course, Switch is in this list (because Damian Conway was the author).
- The post entitled Categorized Damian Modules
Summary: This is the post referred to in Corion's post (that is described above).
I have "set the table". By now, the reader should be thinking "Such a strange module with a strange history". If you are "ready to dine", please read on.
In the recent post by hippo entitled Re^7: Perl Code Changes Behavior if Two Subroutine definitions are swapped, he references a Switch module bug report:
- Bug #86969 for Switch: documentation bugs: deprecatedness, maintainer?
Summary: I offer no summary; I don't want to spoil it for you.
If the reader is still here at this point, it must be because he/she craves still more detail, because the bug report mentioned above should have satiated most of the audience. But, I can offer more for those that are "still hungry".
Here are some Perl Monks threads on the subject. It is not a complete list. For this task, I did a Google search with a query of site:perlmonks.org switch.
- The thread entitled switch statement
Summary: A thread about the Switch module and possible alternatives.
- The thread entitled Switch Module on Perl 5.8.0
- The thread entitled Syntax error with use constant and switch with comment between
Summary: Read this one if you want a chuckle.
- The thread entitled Perl Code Changes Behavior if Two Subroutine definitions are swapped
I hope that this review has convinced the reader that the Switch module should be marked deprecated.
|Replies are listed 'Best First'.|
by CountZero (Bishop) on Aug 07, 2016 at 07:56 UTC