Re: supporting older perls

2007-03-05 Thread Adam Kennedy

As of 5.10, use constant will use less memory than Greg's version.
I'm loathe to make the same changes for 5.8.9, as the implementation
confuses some modules that inspect the symbol table. The necessary
infrastructure will be in 5.8.9 though.


You can add me to the don't want to see it happen side as well.

Correctness and back-compatibility come before performance for me in 
this case.


Adam K


Re: supporting older perls

2007-03-05 Thread Dr.Ruud
Keith Ivey schreef:
 Dr.Ruud:
 Greg Matheson:
 A. Pagaltzis:

 Write the same thing without syntactic sugar from constant.pm.
 sub C1 () { 'C1' }

 Mmh. I see constant.pm does very little.
 
 Well, it nicely sets things up for the compiler to optimize.
 
 perl -MO=Deparse -e 'use constant PI = 3.1415; print PI'
 use constant ('PI', 3.1415);
 print 3.1415;
 -e syntax OK
 
 Greg's version gets optimized as well:
 
 perl -MO=Deparse -e'sub PI () {3.1415} print PI'
 sub PI () { 3.1415 }
 print 3.1415;
 -e syntax OK

Of course, because that is what constant basically does for you. 

-- 
Affijn, Ruud

Gewoon is een tijger.


Re: supporting older perls

2007-03-05 Thread Keith Ivey

Dr.Ruud wrote:

Keith Ivey schreef:

Dr.Ruud:

Greg Matheson:

A. Pagaltzis:



Write the same thing without syntactic sugar from constant.pm.
sub C1 () { 'C1' }

Mmh. I see constant.pm does very little.

Well, it nicely sets things up for the compiler to optimize.

perl -MO=Deparse -e 'use constant PI = 3.1415; print PI'
use constant ('PI', 3.1415);
print 3.1415;
-e syntax OK

Greg's version gets optimized as well:

perl -MO=Deparse -e'sub PI () {3.1415} print PI'
sub PI () { 3.1415 }
print 3.1415;
-e syntax OK


Of course, because that is what constant basically does for you.


Right, that's why Greg said it does very little -- meaning very little 
that the plain sub suggested by A. Pagaltzis doesn't do.  Your response 
to him seemed to be suggesting that it was different.  I guess I 
misinterpreted something.


--
Keith C. Ivey [EMAIL PROTECTED]
Washington, DC


Re: supporting older perls

2007-03-05 Thread Greg Matheson
On Tue, 06 Mar 2007, Adam Kennedy wrote:

 I've now added checking of use constant { ... } to Perl::MinimumVersion 
 as 5.8.0.

 Let me know if this works ok for you.

1.14 reports v5.8.0 if use constant { ... } is in and v5.6.0 if
it is out.

So it works.

 Adam Kennedy wrote:
 Eric Wilhelm wrote:
 I've heard about Perl::MinimumVersion, though it doesn't seem to catch 
 this case in the little test I just tried.  Looking at the source, it 
 certainly seems like it could handle it, though I suspect it would be 
 a good idea to source all of that juicy expert knowledge from data 
 files rather than embedding it in code.  Not sure if Adam has anything 
 in mind for that.  Anyway, some digging suggests this might catch it:

   $doc-find_any(sub {
 $_[1]-isa('PPI::Statement::Include') and
 $_[1]-schild(2)-isa('PPI::Structure::Block')
   });

 Though that could also be a list containing a block (which is actually 
 a hashref, but those don't seem to be distinguished.)

 Never ever heard of that use of use constant to be honest.

 So you've found at least one patch-worth (or commit bit worthy) 
 addition, and by the sound of it on possible bug as well.

 Wanna fix that?

 Adam K

-- 
Greg MathesonIf there is one thing we learn from the 
 study of language learning, it is that
 language learners learn more than we learn.  

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.



Re: supporting older perls

2007-03-04 Thread Dr.Ruud
Greg Matheson schreef:
 A. Pagaltzis:

 Write the same thing without syntactic sugar from constant.pm.
 sub C1 () { 'C1' }
 
 Mmh. I see constant.pm does very little.

Well, it nicely sets things up for the compiler to optimize. 

perl -MO=Deparse -e 'use constant PI = 3.1415; print PI'
use constant ('PI', 3.1415);
print 3.1415;
-e syntax OK

-- 
Affijn, Ruud

Gewoon is een tijger.


Re: supporting older perls

2007-03-04 Thread Keith Ivey

Dr.Ruud wrote:

Greg Matheson schreef:

A. Pagaltzis:



Write the same thing without syntactic sugar from constant.pm.
sub C1 () { 'C1' }

Mmh. I see constant.pm does very little.


Well, it nicely sets things up for the compiler to optimize. 


perl -MO=Deparse -e 'use constant PI = 3.1415; print PI'
use constant ('PI', 3.1415);
print 3.1415;
-e syntax OK


Greg's version gets optimized as well:

perl -MO=Deparse -e'sub PI () {3.1415} print PI'
sub PI () { 3.1415 }
print 3.1415;
-e syntax OK

--
Keith C. Ivey [EMAIL PROTECTED]
Washington, DC


Re: supporting older perls

2007-02-25 Thread Eric Wilhelm
# from Greg Matheson
# on Saturday 24 February 2007 09:02 pm:

I got one failure with 5.6.2 and passes with 5.8. The problem
appears to be the constant pragma, which doesn't seem to have an
independent contemporary existence on CPAN.

It isn't dual-lifed, but at least the docs for the old version are 
available.  Just lookup perl on search.cpan.org and then select an 
older version.  That confirms your suspicion.

  http://search.cpan.org/~rgarcia/perl-5.6.2/lib/constant.pm

How do you find out what can be done in older perls?

I've heard about Perl::MinimumVersion, though it doesn't seem to catch 
this case in the little test I just tried.  Looking at the source, it 
certainly seems like it could handle it, though I suspect it would be a 
good idea to source all of that juicy expert knowledge from data files 
rather than embedding it in code.  Not sure if Adam has anything in 
mind for that.  Anyway, some digging suggests this might catch it:

  $doc-find_any(sub {
$_[1]-isa('PPI::Statement::Include') and
$_[1]-schild(2)-isa('PPI::Structure::Block')
  });

Though that could also be a list containing a block (which is actually a 
hashref, but those don't seem to be distinguished.)

While installing 5.6.2 is no walk in the park with my current compilers 
and such, I was able to copy constant.pm from the source tree into an 
active path and verify that issue with 5.8.4.  Maybe an interesting 
smoke project to test against pure-perl core modules from older 
versions?

--Eric
-- 
You can't win. You can't break even. You can't quit.
--Ginsberg's Restatement of the Three Laws of Thermodynamics
---
http://scratchcomputing.com
---


Re: supporting older perls

2007-02-25 Thread imacat
On Sun, 25 Feb 2007 13:02:11 +0800
Greg Matheson [EMAIL PROTECTED] wrote:
 Here's a message I sent to cpan-testers, but with the volume of
 reports to that list, I doubt anyone on it has time left
 from deleting the messages to respond.

Hi.  I'm a reader of cpan-testers.  I'm using mail filter rules to
classify routine tester reports from discussion posts.  I believe most
of the cpan-testers readers does like me, since I have no problem
discuss with others there.  So I suggest you still post this onto
cpan-testers, since that's where the relative people are.

--
Best regards,
imacat ^_*' [EMAIL PROTECTED]
PGP Key: http://www.imacat.idv.tw/me/pgpkey.txt

Woman's Voice News: http://www.wov.idv.tw/
Tavern IMACAT's: http://www.imacat.idv.tw/
TLUG List Manager: http://lists.linux.org.tw/cgi-bin/mailman/listinfo/tlug


pgpezVnwLQY42.pgp
Description: PGP signature


Re: supporting older perls

2007-02-25 Thread Sébastien Aperghis-Tramoni

Greg Matheson wrote:


I got one failure with 5.6.2 and passes with 5.8. The problem
appears to be the constant pragma, which doesn't seem to have an
independent contemporary existence on CPAN.
[...]
Because it is not failing on 5.8, I suspect that in 5.6.2 the  
constants pragma

didn't have:

   Defining multiple constants at once


Indeed, the constant pragma began supporting this feature with Perl 5.8


Line 16 of my module is:

use constant {
C1= 'C1',
C2= 'C2',

and it continues on this way to line 40.

PREV  = PREV,
COLORS= COLORS,
};

What do I do now? constants doesn't seem to have a contemporary
existence on CPAN distinct from perl.


If you want your module to be compatible with Perl 5.6, you can  
rewrite your statement using multiple use constant calls.  
Otherwise, you can simply add a require 5.008 in your Makefile.PL  
in order to indicate that your module needs Perl 5.8.


--
Sébastien Aperghis-Tramoni

Close the world, txEn eht nepO.




Re: supporting older perls

2007-02-25 Thread Andy Armstrong

On 25 Feb 2007, at 05:02, Greg Matheson wrote:

How do you find out what can be done in older perls?


Is it not possible to build 5.6.2?

Archaeology: this seems to be the birth of use constant:

http://backpan.hexten.net/authors/id/P/PH/PHOENIX/constant-0.01.readme

--
Andy Armstrong, hexten.net



Re: supporting older perls

2007-02-25 Thread Jerry D. Hedden
Greg Matheson wrote:
 How do you find out what can be done in older perls?

Andy Armstrong wrote:
 Is it not possible to build 5.6.2?
 
 Archaeology: this seems to be the birth of use constant:
 

http://backpan.hexten.net/authors/id/P/PH/PHOENIX/constant-0.01.readme

5.6.2 is available here:  http://search.cpan.org/~rgarcia/perl-5.6.2/

I built it under Solaris and use it for testing my modules.


 

Any questions? Get answers on any topic at www.Answers.yahoo.com.  Try it now.


Re: supporting older perls

2007-02-25 Thread A. Pagaltzis
* Greg Matheson [EMAIL PROTECTED] [2007-02-25 06:10]:
 Line 16 of my module is: 
 
   use constant {
   C1= 'C1',
   C2= 'C2',
 
 and it continues on this way to line 40.
 
   PREV  = PREV,
   COLORS= COLORS,
   };
 
 What do I do now? constants doesn't seem to have a contemporary
 existence on CPAN distinct from perl.

Write the same thing without syntactic sugar from constant.pm.

sub C1 () { 'C1' }
sub C2 () { 'C2' }
# ...
sub PREV   () { PREV }
sub COLORS () { COLORS }

-- 
*AUTOLOAD=*_;sub _{s/(.*)::(.*)/print$2,(,$\/, )[defined wantarray]/e;$1}
Just-another-Perl-hack;
#Aristotle


Re: supporting older perls

2007-02-24 Thread Greg Matheson
Here's a message I sent to cpan-testers, but with the volume of
reports to that list, I doubt anyone on it has time left
from deleting the messages to respond.

I got one failure with 5.6.2 and passes with 5.8. The problem
appears to be the constant pragma, which doesn't seem to have an
independent contemporary existence on CPAN.

Module::CoreList tells me that it was 1.02 in 5.6, and 1.04 in
the 5.8.3 I developed my module on.

How do you find out what can be done in older perls?

The message to cpan-testers:

With reference to: 
http://www.mail-archive.com/cpan-testers%40perl.org/msg398745.html

How do I go about finding out what the problem is here?

PERL_DL_NONLAZY=1 /home/david/cpantesting/perl-5.6.2/bin/perl
-MExtUtils::Command::MM -e test_harness(0, 'blib/lib', 
'blib/arch') t/*.t
t/00-load.# Failed test (t/00-load.t at line 20)
# Tried to use 'Games::Tournament::Swiss::Procedure::FIDE'.
# Error:  Constant name 'HASH(0x821c714)' has invalid characters at

/home/david/_/_/perl-5.6.2/.cpan/build/Games-Tournament-Swiss-0.03/blib/lib/Gam
es/Tournament/Swiss/Procedure/FIDE.pm
 line 16
# BEGIN failed--compilation aborted at

/home/david/_/_/perl-5.6.2/.cpan/build/Games-Tournament-Swiss-0.03/blib/lib/Gam
es/Tournament/Swiss/Procedure/FIDE.pm
 line 40.

Because it is not failing on 5.8, I suspect that in 5.6.2 the constants pragma
didn't have:

   Defining multiple constants at once

   Instead of writing multiple use constant statements, you may define
   multiple constants in a single statement by giving, instead of the con-
   stant name, a reference to a hash where the keys are the names of the
   constants to be defined.  Obviously, all constants defined using this
   method must have a single value.

   use constant {
   FOO = A single value,
   BAR = This, won’t, work!,# Error!
   };

Line 16 of my module is: 

use constant {
C1= 'C1',
C2= 'C2',

and it continues on this way to line 40.

PREV  = PREV,
COLORS= COLORS,
};

What do I do now? constants doesn't seem to have a contemporary
existence on CPAN distinct from perl.

--
Dr Bean

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.