John Peacock wrote:
Based on a discussion started on p5p, I have revised the version object code to
always return the initializer string as the stringified version (much like I was
already doing for Module::Build::Version).  Thus what you put in is what you get
out; the sole exception is that the use of qv(1.2) *NOTE* one decimal place and
no leading 'v' *NOTE* will stringify as "v1.2" so we can successfully roundtrip
that value.

I've followed the discussion on p5p loosely as I'm mostly ignorant about version objects (as most users should be, I think).

I don't believe the current version objects support mathematical operations, but it seems something very reasonable to add. (At least, the addition of increment($step)/decrement($step) type ops.)

I wonder how this would affect the consistency of this scheme. If you create a version object. Store the string representation as supplied to the constructor. You will get back that representation exactly. If you the perform an operation on the object and stringify it, you will then get back a possibly different representation. Correct?

$v = version->new('1.01');
print $v . "\n";

$nv = $v + version->new('0.01'); # or maybe $nv = $v->inc('0.01');
print $nv . "\n";

would output:
1.01
1.020

Correct?

versions are numbers. stringification is a lossy operation, just like with numbers. numerical equality does not guarantee string equality. Why not just simplify output by dropping trailing zeros? or making the return representation a configurable or sprintf()-like option?

I'm not trying to add to the argument. More than anything, I'm probably just expressing my ignorance.

Randy.

Reply via email to