Hacker News new | ask | show | jobs
by drabbiticus 331 days ago
I suppose you could argue many things? I would not naively expect Perl's versioning behavior, and a system package manager will have many users who are not Perl devs but who may nevertheless have Perl packages installed on their machines. "There is more than one way to do it" is fine for some things, but I also think it's desirable behavior for a system package manager to only require users to learn a single versioning scheme. In gentoo's case (and in most cases of system package managers I've seen), this happens to be dot-separated sequence of numbers, not floating point.

A system package manager also needs to be able to compare versions, and within gentoo's dot-separated versioning scheme 1.2 < 1.12. However, a perl package could have a dev sequence of 1.1, 1.12, 1.2. If these versions are entered naively into the gentoo packaging scheme, the intended order will not be preserved. So there must be some conversion in order to handle it correctly.

1 comments

Well, for sure it's a mistake to naively expect _anything_ from Perl, of all languages!

I mean, even v-strings themselves ... despite being called version strings, they're different from `version` objects/declarations, and can be used in ways I expect most non-Perl devs might consider unexpected, for example if you run this:

     perl -C2 -E 'say v102.111.111, v128513'
lol what?

For those without perl readily accessible to them, 'v102.111.111' becomes 'foo' and 'v128513' gives you a smiley emoji.

I'm not sure I even want to know.

It turns out[1] that v-strings are strings. So v102.111.111 is a three-character string containing codepoints decimal 102 (f), 111 (o), 111 (o), and v128513 is a one-character string containing codepoint decimal 128513 (U+1F601 GRINNING FACE WITH SMILING EYES).

... Yeah, I don’t know who thought this was a good idea either. I mean, I know versions sort lexicographically and strings do too, but no.

Bonus points:

> If there are two or more dots in the literal, the leading v may be omitted.

So 1 and 1.1 denote numbers, but 1.1.1 and 1.1.1.1 denote strings. I guess there’s a sort of syntactic pun to be had with IPv4 addresses. Still, no.

Bonus bonus points:

> Note that since Perl 5.8.1 the single-number v-strings (like v65) are not v-strings before the => operator (which is usually used to separate a hash key from a hash value); instead they are interpreted as literal strings ('v65').

So v1 always denotes a string, but which string it denotes is context-dependent.

[1] https://perldoc.perl.org/perldata#Version-Strings

I use to love writing Perl. It's great fun to create! But this is exemplary of the reasons I abandoned it in the late 90s.

It's not so much weakly typed as randomly typed.

Which part? The fact that bare words are taken as literal strings before => is one of the very features of => and not random at all.

Likewise, 1.1.1 doesn't have a sensible interpretation as a number, so surely it must be a version? Hardly random.