Git Product home page Git Product logo

Comments (5)

warpfork avatar warpfork commented on June 16, 2024

You've already seen it, but I'll reproduce the comment in there here for posterity/context:

// note: stdlib json.marshal supports all the int types here as well, and will
// tostring them. but this is not supported symmetrically; so we simply... don't.

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 obj/* code understand numeric map keys just fine (like they do, say, byte slices), and have the json/* code reject that, and the cbor/* code also accept it. These comments about json problems being in the obj package are... Yeah, old and stale and misplaced and should be fixed.

from refmt.

warpfork avatar warpfork commented on June 16, 2024

I think this should be pretty easy to fix to handle numerics, and I can try to get to it sometime next week.

from refmt.

warpfork avatar warpfork commented on June 16, 2024

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.

from refmt.

dignifiedquire avatar dignifiedquire commented on June 16, 2024

from refmt.

whyrusleeping avatar whyrusleeping commented on June 16, 2024

@warpfork I need this bad.

from refmt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.