Front page | perl.perl5.porters |
Postings from June 2020
Re: Announcing Perl 7
From: Dave Mitchell
June 25, 2020 08:16
Re: Announcing Perl 7
Message ID: 20200625081620.GG3267@iabyn.com
On Wed, Jun 24, 2020 at 11:49:30PM +0300, Sawyer X wrote:
> * Major versions will be used for two purposes: 1. Turn on features
> and pragmas by default, 2. Remove syntax from the language.
I want to be on the record that I extremely strongly oppose this change.
I think if people want to use the new modern perl, they just put this
one simple line at the top of their code:
this makes everything forward and backwards compatible, and eases the
transition. The thing is that old perl binaries back to at least 5.8.x
recognise this syntax and will produce a helpful error message:
$ perl589 -e'use v7'
Perl v7.0.0 required--this is only v5.8.9, stopped at -e line 1.
this helps everyone: writers of perl7 code will know what the problem
is when they accidentally run their code on an old perl binary, rather
than getting some obscure error message.
Older code continues to run without modification - you don't
have edit every source file to add a 'use compat::perl5' line.
You don't have to update every existing perl installation to add the
compat::perl5 module just so that existing code will continue to run.
CPAN continues to work.
'use v7' also allows the new stuff to be scoped to a single source file;
other .pm files can still be included unmodified using the old perl
Look, we've got this great built-in mechanism, 'use vx.y.z' that's been
around forever. It hasn't seen much use yet, because frankly there's
been very little call for it, since there hasn't been much new
non-backcompat stuff so far. But its been sitting there waiting for use to
In 5 years or whatever, it will also save our bacon when perl8 is
released; suddenly all that source code with 'use v7;' at the top will
continue to work on the perl8 interpreter running in perl7 mode. Rather
than suddenly all breaking.
It helps IDEs as well - now they can look at a source file and know
instantly what major release of perl this file was written against, and
so how to syntax highlight etc.
So 'use v7' benefits *everyone*: the crusty old coders and the shiny new
coders who know nothing about older perl versions. It's a win-win.
I've seen it suggested that not making v7 the default in some fashion
continues to shackle us an overbearing commitment to backwards
compatibility; but I really can't see this - if I'm missing something
please explain it to me.
Given that the v7 release of the perl interpreter will still have to
support both old and new syntax/semantics regardless (so that whatever
internal flags 'use compat::perl5' sets in the interpreter can suitably
alter the behaviour of the lexer and parser), the choice of default makes
no difference to how hard it is to maintain the interpreter.
In fact by far the biggest issue with backwards compatibility in the
interpreter is XS code, especially XS code which relies on stuff outside
the API (or where its not clear whether its API or not). Nothing in the
perl7 proposal (as far as I'm aware) fixes this - it will still be by far
the biggest millstone around our necks in terms of maintaining and
improving the interpreter.
One of the few remaining selling points of perl5 has been the good
backwards compatibility we've offered. If I were a programmer or company
considering investing in perl for the first time, being told that
my effort now won't get broken in 5-10 years time sounds like a good
thing. If not, I might as well invest in one of the other shiny new
languages with no long-term backcompat guarantee.
To be clear, I am completely happy for a bump in version number to 7;
I just want the default behaviour to be as before in the absence of
O Unicef Clearasil!
Gibberish and Drivel!
-- "Bored of the Rings"