-
Notifications
You must be signed in to change notification settings - Fork 870
Add invalid float examples #760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I'm not married to the wording here. Being both clear and concise about this particular point leaves a lot of room for bike-shedding. |
Complementing my comments above I just noticed that the invalid floats example should be moved after the paragraphs explaining how fractional part and exponent part look like, that is in front of the sentence "Similar to integers, you may use...". |
I still consider the first sentence added by the PR as redundant. If I say: "X consists of A followed by B and/or C", then, in my mind, this clearly means that, when talking about X, A will always be there, and at least one of B or C will too. What's unclear about that? Admittedly saying the same thing twice is not so bad and teachers do it quite often – it may help with learning. So I'm not strictly opposed to adding the new sentence – but still feel that, since the first sentence of the same paragraph already says as much and since the new example (added by this PR) makes everything crystal-clear, it would be better to leave it out for the sake of brevity. The rest of the PR is now fine; however, I would still propose to insert the new text ("Note that the decimal point..." and the following example) above the sentence "Similar to integers, you may use..." (leading to the flt8 example) rather than below it. Since the text before that explicitly speaks about the fractional and exponent parts it feels more logical to have the new text there; the underscores issue is something else again, hence it would prefer to see it afterwards. |
It's not a hypothetical problem; I'll remind you again that I made this PR as a result of a real experience I had personally. I've spent a lot of time reading this spec and still the nuance of that point was a surprise to me since I came in with a programming-oriented preconception of what a 'float' is and how it may be represented. My natural feeling was one of "oh I know this!" and I missed a small but significant detail because of it. This sort of mental hop-scotch phenomenon is not unique to me or this situation, mind you; you would have fallen victim to it countless times in your own life, as has everyone. If being a touch more explicit than you feel is necessary helps solve this problem in this particular case going forward, then it's not redundant at all (insofar as redundancy implies waste).
Sure, why not. |
The redundancy doesn't bother me, except it's not technically correct. Leaving off both the fractional part and the exponent part is actually not invalid, but only because doing so makes the value an integer, not a float. Integers are valid TOML, but the consumer of the value could complain if it was expecting a float. So I'm not sure how to best rewrite that latter phrase. |
@eksortso Strictly speaking you could argue that the presence of a decimal point implies a fractional part (which it does in TOML's grammar), and omitting the digits of the fractional part just means it's ill-formed, though given it's valid in other languages that consider the decimal point it's own entity in the grammar etc there's still ambiguity when coming from those contexts. |
I've been using float = float-int-part ( exp / frac [ exp ] )
float =/ special-float
float-int-part = dec-int
frac = decimal-point zero-prefixable-int
decimal-point = %x2E ; .
zero-prefixable-int = DIGIT *( DIGIT / underscore DIGIT ) Though I was aware that many languages allow literals with hanging decimal points for float values, I did consider it better form to require that a decimal point always include at least one digit, for the sake of readability and unobscured identification. That's why I went along with the conversation and didn't say much until now. The ABNF has been moving towards being fully in line with the spec. I'm not sure where its official status stands at this point, but I think we're close to done, so that anything valid per |
@eksortso Yup, I get all that. I'm trying to clearly, explicitly disambiguate the difference in what TOML considers a float versus what many other languages do. When I think "float" I think "a floating-point number as per a thousand different programming languages", not "a floating-point number as TOML would have it", and I'll not be the first to make the mistake of conflating the two. The whole point of this PR is basically to make the point you just did in fewer words. |
@pradyunsg I've moved the first sentence to down with the example, as well as adjusting the wording to essentially combine the two and make it read as less formal in the process. Hopefully closer to what you were driving at. Incidentally, in working on this I've noticed that the repository lacks a |
@marzer Please address the issue that I brought up. If both the fractional part (including the decimal point) and the exponent part are excluded, then what remains is the integer part, not invalid syntax. Could you please revise that part of your proposal? |
@eksortso Huh? Haven't I? The sentence you took issue with isn't in the PR any more. Also, I answered that directly anyway with a rationale to explain why I disagree (insofar as the decimal point implying a fractional is TOML-specific). Neither here nor there now, though. |
My apologies, @marzer. I couldn't tell. I'm still getting used to the app, which is no excuse. Didn't mean to devalue your work, and I'm sorry. |
Clarifies 'floats' section to explicitly demonstrate that omission of integer or fractional+exponent parts isn't legal (closes #759).