kdl-org / kdl

the kdl document language specifications
https://kdl.dev
Other
1.11k stars 61 forks source link

add a note about representations #122

Closed zkat closed 3 years ago

zkat commented 3 years ago

Ref: https://github.com/kdl-org/kdl/issues/121

larsgw commented 3 years ago

Is there a canonical representation of IEEE754 Infinity (and NaN and -Infinity) in KDL? Making them null or removing them entirely could break the resulting document, but there is no Infinity "keyword" in KDL either. Should a writer instead return an exception when an Infinity is passed?

zkat commented 3 years ago

There is not, as far as I know.

Precedent-wise: YAML supports .inf, -.inf, and NaN. JSON has no Infinity or NaN. It just turns things into null afaict.

This PR originally had me adding infinity and nan as keywords but honestly I think that's a bad idea and the answer should be "use a string if you want really big numbers".

As to your question: It's entirely up to you what happens if someone passes in Infinity. It is canonically nasal demons territory. You could throw an error and tell people there's a number overflow/underflow and to use strings instead?

zkat commented 3 years ago

@hkolbeck @larsgw so I've been thinking about this, and how "convenient" the fact that no format for numbers was actually specified in KDL proper. How do y'all feel about not landing this, and just say "numbers are just syntax. Good luck, have fun", and tell users instead to use KDL Schema (or tagging them inline, per #106)?

So if you wanted to say "this is DEFINITELY a u8", you'd do <u8>1.2345? (or whatever syntax we come up with for that, or specify it in the KDL Schema instead)? I feel like I'd rather do that and keep KDL "simple"?

larsgw commented 3 years ago

How do y'all feel about not landing this, and just say "numbers are just syntax. Good luck, have fun", and tell users instead to use KDL Schema (or tagging them inline, per #106)?

So if you wanted to say "this is DEFINITELY a u8", you'd do 1.2345? (or whatever syntax we come up with for that, or specify it in the KDL Schema instead)? I feel like I'd rather do that and keep KDL "simple"?

That's fine with me. I don't really like the tagging myself but specifying in the schema is fine.

As to your question: It's entirely up to you what happens if someone passes in Infinity. It is canonically nasal demons territory. You could throw an error and tell people there's a number overflow/underflow and to use strings instead?

Yeah, I think I prefer errors to silently changing it to JSON.

zkat commented 3 years ago

closing this, then