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

Re: vstring guidance needed

Thread Previous | Thread Next
Nicholas Clark
August 20, 2001 07:23
Re: vstring guidance needed
Message ID:
On Mon, Aug 20, 2001 at 09:21:01AM -0400, John Peacock wrote:
> Rafael Garcia-Suarez wrote:
> > 
> > On 2001.08.17 19:18 John Peacock wrote:

> > > Do we want this:
> > >
> > > SV = PV(0xa011468) at 0xa01f7c8
> > >   REFCNT = 1
> > 
> > I don't understand why pNOK is set here. Did your implementation used
> > a numerical representation while constructing the SV? Looks like the
> > shadow of a bug to me.
> By design, actually.  I need a way to hint that the PV is actually a
> version string, so my current code sets pNOK as a way to imply that 
> there is something special about this SV.  I assume that it would be a
> bit presumptious of me to create a new flag VOK for a version string.

Which routines do you need to hint to?
By setting pNOK (for a non overloaded SV) you will cause the value stored
in the NV slot to be used in numerical contexts, rather than attempting a
conversion of the string. (And as the string is an arbitrary collection of
Unicode code points, that conversion won't make a sane value)

> > Well, PV can be of an arbitrary length, while NV can't. That would speak
> > against the NV. On the other hand, I don't see how "$scalar < v1.2.3"
> > would work without an NV (or IV) equivalent of the vstring PV.
> This is a very good point, and one I wish I had thought of myself.  It
> pretty much clinches it for me that v-strings have to be strings and 
> not numbers.  And, as far as "$scalar < v1.2.3" goes, I am going to 
> try and convince the parser to change that to "$scalar lt v1.2.3" on
> the fly.

Is this easier than documenting that the user should be using lt ?
Nicholas Clark

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