-
Notifications
You must be signed in to change notification settings - Fork 14
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
[cbor] Unable to use numbers as map keys #35
Comments
You've already seen it, but I'll reproduce the comment in there here for posterity/context:
This is a feature I had some questions about implementing because if you use it, you're giving up on the ability to drop in a json encoding, and I think it's worrying to do that without making it clear. And in particular, I still don't approve of an implementation that silently coerces ints to strings in a lossy one-way trip. I think I'm onboard with expanding this, though. The right way to do it is to have the |
I think this should be pretty easy to fix to handle numerics, and I can try to get to it sometime next week. |
Out of curiosity, are you using the entire range of uint64? That seems like some interesting code, if so. I'm brought to wonder because I looked at implementing numeric keys yesterday, and balked because the deterministic ordering sort code as currently written and modified in the most obvious way would get pretty ugly -- especially since it would require both uint64, and int64, all of them -- to work correctly for inputs in the highest half of uint64 -- and probably ought to have int/uint paths for that common case to save casting time as well. I'm pondering whether it's going to turn out better to implement a whole specialized marshalMachine for each numeric type. But that's not without its drawbacks either. Kind of hoping for a better implementation idea to strike me than the ones I've got so far. |
yeah, I will nedd to be able to rely on the fact that any uint I put in works.
…On 6. Oct 2018, 12:15 +0200, Eric Myhre ***@***.***>, wrote:
Out of curiosity, are you using the entire range of uint64? That seems like some interesting code, if so.
I'm brought to wonder because I looked at implementing numeric keys yesterday, and balked because the deterministic ordering sort code as currently written and modified in the most obvious way would get pretty ugly -- especially since it would require both uint64, and int64, all of them -- to work correctly for inputs in the highest half of uint64 -- and probably ought to have int/uint paths for that common case to save casting time as well.
I'm pondering whether it's going to turn out better to implement a whole specialized marshalMachine for each numeric type. But that's not without its drawbacks either. Kind of hoping for a better implementation idea to strike me than the ones I've got so far.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@warpfork I need this bad. |
I am trying to marshal a type
map[uint64]*somestruct
, but cannot do so, as I get the error messagsunsupported map key type "uint64"
. This is really unfortunate, because one of the great things about cbor is that I can use numbers as keys in maps.Code that throws the error: https://github.com/polydawn/refmt/blob/master/obj/marshalMapWildcard.go#L24-L55
The text was updated successfully, but these errors were encountered: