Living with smart match breakage
Gordon Banner
tech at gordonbanner.me.uk
Sat Jun 15 00:03:20 BST 2013
Putting my hand up as one of the idiots...
I've been using given/when for ages. My impression was that it was
announced as a new feature, "yay perl has a case statement (only better)
at last", and I piled in. Maybe I passed danger signals on the way, but
not consciously. Lots of books/presentations promoted it, and I don't
remember the small print.
Marking it as experimental now seems to me to be rewriting history, what
we wish we'd said at the time. The 5.10 perlsyn page for example does
not give any warnings at all.
I defend the option to change the language and remove broken stuff, but
I'm slightly peeved to be labelled a bleeding-edge cowboy for using
something that has been promoted widely for years.
A quote from the 4th edition Camel, at the end of *5 pages* of
discussion of given/when:
"We still consider some of the darker corners of given and when to
be experimental, but please be assured that in practice most of your
switch statements are likely to be based on simple string or number
matches, and these will always work the way you expect."
I want my matches - just about all of them simple string or number
matches - to "always work", please.
Finally, the OP mentioned "convoluted boilerplate" and was offered
no warnings 'experimental::smartmatch';
# or
use experimental 'smartmatch';
If you think that's memorable and quick to type, your brain and fingers
must move faster than mine, or you program in an IDE. By the time
you've knocked that lot out you might as well type a bunch of elsifs anyway.
Slightly more annoyed than I expected to be at the beginning of this rant,
Gordon
On 14/06/2013 16:09, Graeme Hewson wrote:
> On Friday 14 Jun 2013 16:29:23 Abigail wrote:
>
>> (If you hire more than a handful of new devs each month,
>> someone will not have gotten the memo).
> Some people will think they /have/ got the memo because the feature's been
> written about in the Camel book, Modern Perl, and no doubt other books too.
More information about the london.pm
mailing list