Open sfackler opened 6 years ago
Adding a deprecation warning sounds reasonable to me. Long term it does seem desirable to disallow such usage. We've spoken about this exact issue before and from what I recall the only reason we didn't remove set<double>
and map<double, V
from the language was out of concern for breaking current usage.
+1 I am currently working on jumping through hoops to support these types in conjure-go (which does not natively support json-encoding of floating point map keys, and will straight-up fail to serialize NaN (which is not comparable) without a very custom implementation)
@carterkozak This might be an interesting one to add to the --strict
flag?
Follow up note here - conjure-rust does now support these types, but via a bit of a gross API and I think they're semantically a bit iffy in general due to precision issues: https://github.com/palantir/conjure-rust/pull/155
Floating point keys are currently allowed as keys in map and set types. This poses particular problems for the Rust Conjure implementation, where floating point values can't be used as keys in set and map types. We could in theory fix this but only through pretty drastic measures like having our own custom collection types and associated traits. Instead, I'm just planning on not supporting
set<double>
andmap<double, V>
in generated code.Beyond that specific language integration issue, floating point keys are a bit iffy generally IMO since it's so easy to drift just slightly off of the exact numeric value that you're expecting. It seems like it might be best to discourage the use of these types minimally.