develooper Front page | perl.perl5.porters | Postings from December 2017

Re: Revisiting smart match

Thread Previous | Thread Next
From:
Tom Molesworth via perl5-porters
Date:
December 26, 2017 16:05
Subject:
Re: Revisiting smart match
Message ID:
CAGXhHd=uNanYgohojyMX3k7wohmKTk7+jL+O-bZeeFPSiHsvKQ@mail.gmail.com
On 25 December 2017 at 23:52, David Golden <xdg@xdg.me> wrote:
>
> I think it's generally accepted wisdom now (in several dynamic languages communities, not just Perl) that people should run applications using their own interpreter, not the system one.


Generally-accepted in some circles, perhaps, but I'd suggest it's by
no means a universal standard - for beginners especially, my
experience is that the system packages are seen as the safe option. My
sample size is small, but I find that most people use system Perl, and
the same applies to Python, node.js and bash.

>
>   So who suffers if a newer Perl breaks stuff?  People who don't follow the wisdom?  They can learn why it's a widely used pattern.  Sysadmins who have scripts they want to "just work" on newer OSes?  They're sysadmins... I expect them to be able to install their own Perl and use it if they need to.  Newbies?  They aren't using experimental features anyway.


Proliferation of Perls aside... I don't think that last one is a fair
assessment of the impact:

- if it's an old perl, this is *not* an experimental feature (as
mentioned a few times elsewhere).
- we were recommending given/when and smartmatch in the FAQ until very recently.
- in my experience, "how do I check for a value in array" and "how do
I spell switch/case in Perl" seem to be common questions for Perl
newcomers which end(ed) up with a smartmatch-related answer.

"Very recently" includes Perl 5.26.1, which *explicitly recommends*
given/when in the current text:

http://perldoc.perl.org/perlfaq7.html#How-do-I-create-a-switch-or-case-statement%3f

Note that it does mention Switch.pm as being discouraged... yet makes
no mention of impending changes in newer Perl versions.

I think this can be taken as an authoritative learning source for Perl
programmers - it seems premature to change the feature when the
officially-sanctioned examples will break?

The standard recommendation for new features - e.g. async/await, which
I am very much looking forward to - seems to be "do it in CPAN, and if
it's popular or important enough, we can consider moving it to core".
How feasible would that approach be for either smartmatch, or some
form of switch/case? (I'm not convinced that the two concepts need to
be so tightly integrated as they have been so far - not that I'm a
target user, I don't see much value in either of them in the first
place for the code I tend to write).

Just to be clear, I don't agree with the stronger negative opinions
either: from my perspective the new smartmatch approach seems like a
significant improvement, and if we'd started with this I think it'd be
a great addition to the language.

thanks,

Tom

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About