You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by kf...@collab.net on 2004/03/03 05:57:49 UTC

question about r8708 (Perl warning pragmas)

r8708 applies a patch like this to three Perl hook scripts:

   -# The warning switch is set here and not in the shebang line above
   -# with /usr/bin/env because env will try to find the binary named
   -# 'perl -w', which won't work.
   -BEGIN
   -  {
   -    $^W = 1;
   -  }
   -
   +require 5.6.0;  #  minimum Perl version for "warnings" module
   +use warnings;

Some time ago, Ben Collins-Sussman and I looked at this and wondered
why the "require 5.6.0;" line wasn't controversial.  Ben Reser
mentioned once that it wasn't, but I don't remember if he said why.
Was it that the scripts already effectively require Perl 5.6.0 (by
virtue of depending on some feature), so making the requirement
explicit doesn't actually add any restrictions?  Or was there some
other reason why forcing >= 5.6.0 is okay?

Oh, and, why am I asking this now? :-)

Because Mike Pilato and I were looking at r8708 in 1.0.x/STATUS, to
possibly vote on it.  However, we want to make sure that it's not
adding a Perl version requirement that we didn't previously have.  Or,
if it *is* adding a requirement, then it's one that's been discussed &
agreed on.  We couldn't find anything in the list archives, so we're
asking here.

Thanks,
-Karl & Mike

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: question about r8708 (Perl warning pragmas)

Posted by John Peacock <jp...@rowman.com>.
Ben Reser wrote:

> Using the better method on the newer perls and the old method on the
> older ones.  Before someone asks.  I tried to use $] and $^V to handle
> the version test.  It wasn't very cooperative.  

$^V isn't going to work for you, but $] will work fine like this:

BEGIN {
   if ( $] >= 5.006_000)
     { require warnings; import warnings; print qq(warnings\n); }
   else
     { $^W = 1; print qq(^W\n);}
}
$x = 1;

which works for all versions of Perl that I have to test with.

John

-- 
John Peacock
Director of Information Research and Technology
Rowman & Littlefield Publishing Group
4501 Forbes Boulevard
Suite H
Lanham, MD  20706
301-459-3366 x.5010
fax 301-429-5748

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: question about r8708 (Perl warning pragmas)

Posted by Ben Reser <be...@reser.org>.
On Thu, Mar 04, 2004 at 02:41:38PM +0000, Colin Watson wrote:
> On Tue, Mar 02, 2004 at 11:57:49PM -0600, kfogel@collab.net wrote:
> > r8708 applies a patch like this to three Perl hook scripts:
> > 
> >    -# The warning switch is set here and not in the shebang line above
> >    -# with /usr/bin/env because env will try to find the binary named
> >    -# 'perl -w', which won't work.
> >    -BEGIN
> >    -  {
> >    -    $^W = 1;
> >    -  }
> >    -
> >    +require 5.6.0;  #  minimum Perl version for "warnings" module
> >    +use warnings;
> > 
> > Some time ago, Ben Collins-Sussman and I looked at this and wondered
> > why the "require 5.6.0;" line wasn't controversial.
> 
> For an entirely separate reason than the version requirement itself,
> 'require 5.6.0;' isn't a very good idea. Here's why:
> 
>   $ perl -MConfig -le 'print $Config{version}'
>   5.00503
>   $ perl -e 'require 5.6.0;'
>   Can't locate 5.60 in @INC (@INC contains: /usr/lib/perl5/5.005/i386-linux /usr/lib/perl5/5.005 /usr/local/lib/site_perl/i386-linux /usr/local/lib/site_perl /usr/lib/perl5 .) at -e line 1.
>   $ perl -e 'require 5.006;'
>   Perl 5.006 required--this is only version 5.00503, stopped at -e line 1.
> 
> Versions older than 5.6.0 didn't understand the "5.6.0" syntax for
> versions, so you should use the "5.006" form instead. Both will fail,
> but the former gives a very confusing and misleading error message.

Even changing the versioning syntax to the old style will still not give
a nice version error:

$ perl5.00503 -e 'require 5.006_000; use warnings;'
Can't locate warnings.pm in @INC (@INC contains:
/usr/local/lib/perl5/5.00503/sun4-solaris /usr/local/lib/perl5/5.00503
/usr/local/lib/perl5/site_perl/5.005/sun4-solaris
/usr/local/lib/perl5/site_perl/5.005 .) at -e line 1.
BEGIN failed--compilation aborted at -e line 1.
Exit 2

It works.  But the use gets run before it anyway.  So the require is
pointless:

$ perl5.00503 -e 'require 5.006_000; print q(foo)'
Perl 5.006 required--this is only version 5.00503, stopped at -e line 1.
Exit 255

So the require line will never run unless they have 5.6.0 anyway.  That
means at this point in time it's more of a documentation than an
effective requirement.

Wrapping it in a BEGIN block would avoid this:
$ perl5.00503 -e 'BEGIN { require 5.006_000;} use warnings;'
Perl 5.006 required--this is only version 5.00503, stopped at -e line 1.
BEGIN failed--compilation aborted at -e line 1.
Exit 255

Someone else suggested we wrap it in an eval block.  We can do something
like this and then it'll work on all perl5 versions:
$ perl5.00503 -e 'BEGIN { if (eval "require 5.006_000;") { require
warnings; import warnings; print qq(warnings\n); } else { $^W = 1; print
qq(^W\n);}} $x = 1;'
^W
Name "main::x" used only once: possible typo at -e line 1.

$ perl5.6.0  -e 'BEGIN { if (eval "require 5.006_000;") { require
warnings; import warnings; print qq(warnings\n); } else { $^W = 1; print
qq(^W\n);}} $x = 1;'
warnings
Name "main::x" used only once: possible typo at -e line 1.

Using the better method on the newer perls and the old method on the
older ones.  Before someone asks.  I tried to use $] and $^V to handle
the version test.  It wasn't very cooperative.  I didn't "use warnings"
here because that creates its own BEGIN block which will end up getting
evaluated before the one I wrote.
 
-- 
Ben Reser <be...@reser.org>
http://ben.reser.org

"Conscience is the inner voice which warns us somebody may be looking."
- H.L. Mencken

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: question about r8708 (Perl warning pragmas)

Posted by Colin Watson <cj...@flatline.org.uk>.
On Thu, Mar 04, 2004 at 09:22:46AM -0800, Daniel L. Rall wrote:
> Colin Watson wrote:
> >On Tue, Mar 02, 2004 at 11:57:49PM -0600, kfogel@collab.net wrote:
> >>  +require 5.6.0;  #  minimum Perl version for "warnings" module
> >>  +use warnings;
> >>
> >>Some time ago, Ben Collins-Sussman and I looked at this and wondered
> >>why the "require 5.6.0;" line wasn't controversial.
> >
> >For an entirely separate reason than the version requirement itself,
> >'require 5.6.0;' isn't a very good idea. Here's why:
> >
> >  $ perl -MConfig -le 'print $Config{version}'
> >  5.00503
> >  $ perl -e 'require 5.6.0;'
> >  Can't locate 5.60 in @INC (@INC contains: 
> >  /usr/lib/perl5/5.005/i386-linux /usr/lib/perl5/5.005 
> >  /usr/local/lib/site_perl/i386-linux /usr/local/lib/site_perl 
> >  /usr/lib/perl5 .) at -e line 1.
> >  $ perl -e 'require 5.006;'
> >  Perl 5.006 required--this is only version 5.00503, stopped at -e line 1.
> >
> >Versions older than 5.6.0 didn't understand the "5.6.0" syntax for
> >versions, so you should use the "5.006" form instead. Both will fail,
> >but the former gives a very confusing and misleading error message.
> 
> Alternatively, could the 'use warnings;' (the reason for the 'require 
> 5.6.0;') be wrapped in an eval {} to provide the equivalent of 'require 
> 5.6.0;'?

I'm not quite sure what you mean (wouldn't that weaken the
requirement?), but indeed it occurs to me that with 'use warnings;' the
require is almost useless:

  $ perl -MConfig -le 'print $Config{version}'
  5.00503
  $ perl -e 'require 5.6.0; use warnings;'
  Can't locate warnings.pm in @INC (@INC contains: /usr/lib/perl5/5.005/i386-linux /usr/lib/perl5/5.005 /usr/local/lib/site_perl/i386-linux /usr/local/lib/site_perl /usr/lib/perl5 .) at -e line 1.

The require should probably be in a BEGIN block.

-- 
Colin Watson                                  [cjwatson@flatline.org.uk]

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: question about r8708 (Perl warning pragmas)

Posted by "Daniel L. Rall" <dl...@collab.net>.
Colin Watson wrote:
> On Tue, Mar 02, 2004 at 11:57:49PM -0600, kfogel@collab.net wrote:
> 
>>r8708 applies a patch like this to three Perl hook scripts:
>>
>>   -# The warning switch is set here and not in the shebang line above
>>   -# with /usr/bin/env because env will try to find the binary named
>>   -# 'perl -w', which won't work.
>>   -BEGIN
>>   -  {
>>   -    $^W = 1;
>>   -  }
>>   -
>>   +require 5.6.0;  #  minimum Perl version for "warnings" module
>>   +use warnings;
>>
>>Some time ago, Ben Collins-Sussman and I looked at this and wondered
>>why the "require 5.6.0;" line wasn't controversial.
> 
> 
> For an entirely separate reason than the version requirement itself,
> 'require 5.6.0;' isn't a very good idea. Here's why:
> 
>   $ perl -MConfig -le 'print $Config{version}'
>   5.00503
>   $ perl -e 'require 5.6.0;'
>   Can't locate 5.60 in @INC (@INC contains: /usr/lib/perl5/5.005/i386-linux /usr/lib/perl5/5.005 /usr/local/lib/site_perl/i386-linux /usr/local/lib/site_perl /usr/lib/perl5 .) at -e line 1.
>   $ perl -e 'require 5.006;'
>   Perl 5.006 required--this is only version 5.00503, stopped at -e line 1.
> 
> Versions older than 5.6.0 didn't understand the "5.6.0" syntax for
> versions, so you should use the "5.006" form instead. Both will fail,
> but the former gives a very confusing and misleading error message.

Alternatively, could the 'use warnings;' (the reason for the 'require 5.6.0;') 
be wrapped in an eval {} to provide the equivalent of 'require 5.6.0;'?



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: question about r8708 (Perl warning pragmas)

Posted by Colin Watson <cj...@flatline.org.uk>.
On Tue, Mar 02, 2004 at 11:57:49PM -0600, kfogel@collab.net wrote:
> r8708 applies a patch like this to three Perl hook scripts:
> 
>    -# The warning switch is set here and not in the shebang line above
>    -# with /usr/bin/env because env will try to find the binary named
>    -# 'perl -w', which won't work.
>    -BEGIN
>    -  {
>    -    $^W = 1;
>    -  }
>    -
>    +require 5.6.0;  #  minimum Perl version for "warnings" module
>    +use warnings;
> 
> Some time ago, Ben Collins-Sussman and I looked at this and wondered
> why the "require 5.6.0;" line wasn't controversial.

For an entirely separate reason than the version requirement itself,
'require 5.6.0;' isn't a very good idea. Here's why:

  $ perl -MConfig -le 'print $Config{version}'
  5.00503
  $ perl -e 'require 5.6.0;'
  Can't locate 5.60 in @INC (@INC contains: /usr/lib/perl5/5.005/i386-linux /usr/lib/perl5/5.005 /usr/local/lib/site_perl/i386-linux /usr/local/lib/site_perl /usr/lib/perl5 .) at -e line 1.
  $ perl -e 'require 5.006;'
  Perl 5.006 required--this is only version 5.00503, stopped at -e line 1.

Versions older than 5.6.0 didn't understand the "5.6.0" syntax for
versions, so you should use the "5.006" form instead. Both will fail,
but the former gives a very confusing and misleading error message.

-- 
Colin Watson                                  [cjwatson@flatline.org.uk]

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: question about r8708 (Perl warning pragmas)

Posted by Ben Reser <be...@reser.org>.
On Wed, Mar 03, 2004 at 03:36:47PM -0500, Greg Hudson wrote:
> Does r8708 introduce a practical benefit of any kind?  (I realize it
> introduces a correctness benefit, but that's not an argument for
> including it in 1.0.x.)

Probably not unless someone starts hacking onto it and making it use
modules that like to spit out warnings.

It's not the end of the world if it doesn't go in.

-- 
Ben Reser <be...@reser.org>
http://ben.reser.org

"Conscience is the inner voice which warns us somebody may be looking."
- H.L. Mencken

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: question about r8708 (Perl warning pragmas)

Posted by Greg Hudson <gh...@MIT.EDU>.
Does r8708 introduce a practical benefit of any kind?  (I realize it
introduces a correctness benefit, but that's not an argument for
including it in 1.0.x.)


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: question about r8708 (Perl warning pragmas)

Posted by Ben Reser <be...@reser.org>.
On Tue, Mar 02, 2004 at 11:57:49PM -0600, kfogel@collab.net wrote:
> Some time ago, Ben Collins-Sussman and I looked at this and wondered
> why the "require 5.6.0;" line wasn't controversial.  Ben Reser
> mentioned once that it wasn't, but I don't remember if he said why.
> Was it that the scripts already effectively require Perl 5.6.0 (by
> virtue of depending on some feature), so making the requirement
> explicit doesn't actually add any restrictions?  Or was there some
> other reason why forcing >= 5.6.0 is okay?

Okay here's the logic:

5.6.0 will be 4 years old on March 23rd, 2004.

We already require 5.8 for bindings and building on windows.

The version issue was brought up by Blair:
http://www.contactor.se/~dast/svn/archive-2004-02/0233.shtml

If you read the thread there was some comments about it but nobody
really objected strongly.  

> Oh, and, why am I asking this now? :-)
> 
> Because Mike Pilato and I were looking at r8708 in 1.0.x/STATUS, to
> possibly vote on it.  However, we want to make sure that it's not
> adding a Perl version requirement that we didn't previously have.  Or,
> if it *is* adding a requirement, then it's one that's been discussed &
> agreed on.  We couldn't find anything in the list archives, so we're
> asking here.

Well they are hook scripts.  So it's not a requirement per se.  Nobody
is forced to use these.  If someone really wants to use an older perl
they could always switch them back to the way they are now.  And anyone
currently using the scripts will still have them working with the older
perl.

I'd be surprised if there are any commonly used platforms that don't at
least come with 5.6.0 (except for Windows which is a whole different
thing but you know what I mean).

-- 
Ben Reser <be...@reser.org>
http://ben.reser.org

"Conscience is the inner voice which warns us somebody may be looking."
- H.L. Mencken

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org