develooper Front page | perl.perl5.porters | Postings from August 2001


Thread Previous | Thread Next
John Peacock
August 24, 2001 13:26
Message ID:
Abigail wrote:
> On Thu, Aug 23, 2001 at 12:31:30PM -0400, John Peacock wrote:
> > Rafael Garcia-Suarez wrote:
> > >
> > > And this seems a little bit too DWIMmy: I expect "5.6.1" to be
> > > equivalent to v53. At least on ASCII machines.
> >
> > Why would you imagine it would do that?
> Eh, because it currently does, and that behaviour is documented?
>     $ perl -wle 'print "Yes" if "5.6.1" eq v53.'
>     Yes
>     $

This whole thread is completely missing the point.  All I am trying 
to do is make version comparisons consistent.  Period, end of 
sentence.  I am not trying to change v-string behavior as currently 
documented.  I don't understand Unicode equality in the slightest, 
nor is it likely I will learn it before Perl6 comes out.

All I want to do is take anything that's USED as a version, 
upgrade it to v-string if it isn't already, and then use that vstring
when comparing versions (say in CPAN or Exporter).  What I envision
is that the following:

	$VERSION = v5.6.1;	# tokenized to v-string
	$VERSION = 5.6.1;	# ditto
	$VERSION = "5.6.1";	# upgraded for test
	$VERSION = 5.006_001;	# one I cannot handle just yet

all compare as the same version; but ONLY when compared as versions.
You can still do '$VERSION eq v53.' since I have not done
anything to $VERSION.  I only converted it to a v-string when I was
testing it AS A VERSION.

Let's see how far that concept goes:

	$VERSION     = v20001102;
	$NEW_VERSION = v20010101;
	print "newer\n"
	    if $VERSION lt $NEW_VERSION; 

works fine.  But I am not even talking about DWIMming it that far;
The only code that will make use of my changes will be 
UNIVERSAL::VERSION (and Exporter, which will inherit from that (and
CPAN which will probably inherit from Exporter)).  That's it.  The
version strings will not be visible from user space (as such).  I am
not planning on adding a toke pass to run force_version() anything
the parser sees something like VERSION.

I am only proposing to use v-strings as the one and only method by
which Perl decides whether one version is higher than another. 
v-strings happen to sort in a natural order which allows this to 
DWIM, where ASCII is wrong sometimes and numeric testing is prone to 
notation errors.  Nothing I am doing changes v-strings (except for 
extracting the code from toke.c:scan_num).  Anything the three people 
on the list who understand Unicode can do, they can still do. ;~)

I am nowhere near the point where I can alter the nature of Perl.
I am just trying to shim in a little code here and there to do 
one thing: compare versions using v-strings.

Thanks for listening


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About