ivoa-std / VOUnits

Units in the VO
Creative Commons Attribution Share Alike 4.0 International
0 stars 4 forks source link

The definition of the VOUFLOAT terminal permits '0.0'; it shouldn't #32

Closed nxg closed 12 months ago

nxg commented 12 months ago

The regexp defining VOUFLOAT is intended to exclude 0, because that's meaningless. It syntactically permits 0.0, however, though this would be just as meaningless.

I propose adding to the definition here something like

...and does not match 0\.0*([eE][+-]?[0-9]+)

I don't think there's a more compact way of specifying this, other than with an excessively complicated regexp.

It did occur to me to add some clarifying text to the effect that ‘A unit string of 0.0 is syntactically permitted but...’ and couldn't settle on a way to finish the sentence that was sufficiently discouraging but which still fell short of amending the spec in this way.

If this seems reasonable, I'll confirm that there are no gotchas by implementing it in the Unity lexer.

mbtaylor commented 12 months ago

I don't have strong opinions, but in general I don't feel that it's essential for the grammar to exclude all possible stupid ways for people to abuse VOUnits syntax; if you really want to write 0.0km/s in a units field you deserve what you get. So I'd personally be relaxed about doing nothing here.

nxg commented 12 months ago

What had occurred to me is the prospect of some bright spark deciding to use 0.0m as a null value in some context I don't much want to think about. Perhaps we should leave that unspecified but highly disrecommended, and I wrote some words to that effect. But it turned into more words than I expected, and it looked quicker just to say ‘don't even think about it’.

msdemlei commented 12 months ago

On Thu, Sep 14, 2023 at 04:00:57AM -0700, Mark Taylor wrote:

I don't have strong opinions, but in general I don't feel that it's essential for the grammar to exclude all possible stupid ways for people to abuse VOUnits syntax; if you really want to write 0.0km/s in a units field you deserve what you get. So I'd personally be relaxed about doing nothing here.

Agreed; plus it's inconvenient to write in BNF, which for me is a sign that perhaps what you're trying to do perhaps belongs somewhere else but in the grammar.

So, Norman, unless you'd very much like to have this formally specified... would you very much dislike just writing "zero scale factors are forbidden" somewhere?

nxg commented 12 months ago

Again, the magic text in the commit message was supposed to close this issue, but hasn't. So closing...