Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Why is "use 5.010" necessary

0 views
Skip to first unread message

zaphod

unread,
Nov 24, 2009, 11:36:17 AM11/24/09
to
Why is it necessary to state:

use 5.010;

... simply to have access to Perl 5.10's features? If I didn't want to use it's features I wouldn't have installed it in the first place. 5.10 is backwards compatible in any case so it all seems a bit pointless.

zaphod

Ben Morrow

unread,
Nov 24, 2009, 12:57:07 PM11/24/09
to

Quoth zaphod <a...@def.com>:

It's only necessary to say that if you want a feature that might be
incompatible with code written for previous versions of Perl. For
instance, the '//' operator is always available, but the 'say' operator
isn't, in case you have some code that uses a sub called 'say'.

Ben

zaphod

unread,
Nov 24, 2009, 5:55:19 PM11/24/09
to

So the whole Perl community has to put 'use 5.010;' in every Perl program they write for eternity just because someone might have a sub called 'say' somewhere in their old code that they're now running under Perl 5.10? Mistaken priorties surely?

zaphod

Ben Morrow

unread,
Nov 24, 2009, 6:53:59 PM11/24/09
to

Quoth zaphod <a...@def.com>:

> On 24/11/2009 17:57, Ben Morrow wrote:
> > Quoth zaphod<a...@def.com>:
> >> Why is it necessary to state:
> >>
> >> use 5.010;
> >>
> >> ... simply to have access to Perl 5.10's features? If I didn't want to
> >> use it's features I wouldn't have installed it in the first place. 5.10
> >> is backwards compatible in any case so it all seems a bit pointless.
> >
> > It's only necessary to say that if you want a feature that might be
> > incompatible with code written for previous versions of Perl. For
> > instance, the '//' operator is always available, but the 'say' operator
> > isn't, in case you have some code that uses a sub called 'say'.
>
> So the whole Perl community has to put 'use 5.010;' in every Perl
> program they write for eternity just because someone might have a sub
> called 'say' somewhere in their old code that they're now running under
> Perl 5.10?

Yes. Apart from anything else, encouraging people to put a compile-time
version requirement is a Good Thing. A sane and straightforward error
message is a lot better than a series of confusing syntax errors.

You should be thankful that 'use 5.010' is sufficient. IIRC there was
quite some objection to that idea when it was proposed (on the grounds
that it was confusing and changed the semantics of 'use VERSION') so you
might have been left needing an explicit 'use feature' line.

> Mistaken priorties surely?

You should check out the archives of p5p :). This is a conversation that
has been had many many times, with vocal arguments on both sides. The
current policies on backwards-compatibility are necessarily a
compromise, IMHO a reasonable one.

Ben

Uri Guttman

unread,
Nov 24, 2009, 7:04:13 PM11/24/09
to
>>>>> "z" == zaphod <a...@def.com> writes:

z> On 24/11/2009 17:57, Ben Morrow wrote:
>> Quoth zaphod<a...@def.com>:
>>> Why is it necessary to state:
>>>
>>> use 5.010;
>>>
>>> ... simply to have access to Perl 5.10's features? If I didn't want to
>>> use it's features I wouldn't have installed it in the first place. 5.10
>>> is backwards compatible in any case so it all seems a bit pointless.
>>
>> It's only necessary to say that if you want a feature that might be
>> incompatible with code written for previous versions of Perl. For
>> instance, the '//' operator is always available, but the 'say' operator
>> isn't, in case you have some code that uses a sub called 'say'.
>>
>> Ben
>>

z> So the whole Perl community has to put 'use 5.010;' in every Perl
z> program they write for eternity just because someone might have a
z> sub called 'say' somewhere in their old code that they're now
z> running under Perl 5.10? Mistaken priorties surely?

no, it is called backwards compatability. perl has always had that in
mind and with 5.10 they made serious changes in adding functions and
some syntax that would break older programs. as perl could be upgraded
without changed the programs (happens all the time on shared servers,
etc.) that would cause many programs to break for no obvious reason. so
the priority is well chosen here. if you want those new 5.10 features
you must explicitly enable them in your program.

uri

--
Uri Guttman ------ u...@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------

zaphod

unread,
Nov 24, 2009, 7:13:21 PM11/24/09
to
On 25/11/2009 00:04, Uri Guttman wrote:
> no, it is called backwards compatability. perl has always had that in
> mind and with 5.10 they made serious changes in adding functions and
> some syntax that would break older programs. as perl could be upgraded
> without changed the programs (happens all the time on shared servers,
> etc.) that would cause many programs to break for no obvious reason. so
> the priority is well chosen here. if you want those new 5.10 features
> you must explicitly enable them in your program.
>
> uri
>

So when we get to Perl 5.12 and 5.14 are we going to have to remember exactly which features were added in exactly which versions and add 'use 5.0xx' accordingly? I envisage Perl programming getting a lot more messy. Furthermore, why did I not have to include 'use 5.08x' following the release of Perl 5.8?

The day Perl starts adding lines at the top of scripts to appease the Perl-indifference of shared hosting providers is the day I reconsider using it. That's just not the Perl way.

zaphod

Ben Morrow

unread,
Nov 24, 2009, 8:00:06 PM11/24/09
to

Quoth zaphod <a...@def.com>:

> On 25/11/2009 00:04, Uri Guttman wrote:
> > no, it is called backwards compatability. perl has always had that in
> > mind and with 5.10 they made serious changes in adding functions and
> > some syntax that would break older programs. as perl could be upgraded
> > without changed the programs (happens all the time on shared servers,
> > etc.) that would cause many programs to break for no obvious reason. so
> > the priority is well chosen here. if you want those new 5.10 features
> > you must explicitly enable them in your program.
>
> So when we get to Perl 5.12 and 5.14 are we going to have to remember
> exactly which features were added in exactly which versions and add 'use
> 5.0xx' accordingly?

Yes. You should be doing this anyway. If you want to take a shortcut,
you can always just 'use' the version of perl you happen to be
developing on.

> I envisage Perl programming getting a lot more
> messy. Furthermore, why did I not have to include 'use 5.08x' following
> the release of Perl 5.8?

Because 5.8 didn't add any new keywords that might conflict with
existing code.

> The day Perl starts adding lines at the top of scripts to appease the
> Perl-indifference of shared hosting providers is the day I reconsider
> using it. That's just not the Perl way.

And yet there are people who yell blue murder if a script that was
written for Perl 3 fails to work as designed on the latest release. I
suggest you catch up on some of the last 20 years of p5p before you
start making pronouncements about what is and isn't 'the Perl way'.

Ben

Dr.Ruud

unread,
Nov 24, 2009, 8:26:23 PM11/24/09
to
zaphod wrote:

> So the whole Perl community has to put 'use 5.010;' in every Perl
> program they write

TIMTOWTDI: PERL5OPT.

--
Ruud

Tad McClellan

unread,
Nov 24, 2009, 8:46:58 PM11/24/09
to
Ben Morrow <b...@morrow.me.uk> wrote:
> Quoth zaphod <a...@def.com>:
>> On 24/11/2009 17:57, Ben Morrow wrote:
>> > Quoth zaphod<a...@def.com>:
>> >> Why is it necessary to state:
>> >>
>> >> use 5.010;
>> >>
>> >> ... simply to have access to Perl 5.10's features?

>> Mistaken priorties surely?


>
> You should check out the archives of p5p :). This is a conversation that
> has been had many many times, with vocal arguments on both sides. The
> current policies on backwards-compatibility are necessarily a
> compromise, IMHO a reasonable one.


But it is not what zaphod would have chosen, and is therefore foolish!


--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"

Shmuel Metz

unread,
Nov 25, 2009, 6:26:32 PM11/25/09
to
In <zaudnY1MvYkclpHW...@brightview.co.uk>, on 11/24/2009

at 04:36 PM, zaphod <a...@def.com> said:

>Why is it necessary to state:

>use 5.010;

>.... simply to have access to Perl 5.10's features?

So that those running an older version of Perl will get a sensible error
message.

>If I didn't want to use it's features I wouldn't have installed it in
>the first place.

K3wl; there's only one program on your machine written in Perl? Because if
there are two then there's no guaranty that you want to use the new
features of Perl 5.10 in both. If you're distributing your code to the
outside world, then it is reasonable to indicate in the code the oldest
version of Perl that you support.

>5.10 is backwards compatible in any case so it all seems a bit
>pointless.

Only for those who never share code with anybody else.

--
Shmuel (Seymour J.) Metz, SysProg and JOAT <http://patriot.net/~shmuel>

Unsolicited bulk E-mail subject to legal action. I reserve the
right to publicly post or ridicule any abusive E-mail. Reply to
domain Patriot dot net user shmuel+news to contact me. Do not
reply to spam...@library.lspace.org

0 new messages