Coder Social home page Coder Social logo

Comments (4)

neild avatar neild commented on June 2, 2024 1

You'd also want to rename the types in the proto, encoding/prototext, and encoding/protojson packages.

It's been a while, but I think we went with MarshalOptions/UnmarshalOptions, because the older proto package has proto.Unmarshaler and proto.Marshaler types that are interfaces describing a type which can marshal/unmarshal itself. Using a different name for the options type had less potential for confusion.

Renaming UnmarshalOptions and adding type UnmarshalOptions = Unmarshaler might not be a backwards-compatible change; I don't know how likely it is to cause breakage, but it will be user-visible to code using reflection to inspect types. If TGP and the ecosystem metrics pipeline report no problems, it's probably fine, though.

Personally, I'm dubious that the improvement is worth the churn. protodelim.UnmarshalOptions is probably not used much, but proto.UnmarshalOptions is.

from protobuf.

dsnet avatar dsnet commented on June 2, 2024 1

Renaming MarshalOptions as Marshaler sounds fine to me as long as the naming convention is consistently applied.
I can't quite remember, but I believe @neild is correct that the pre-existing Marshaler and Unmarshaler types were why the name wasn't chosen. IIRC, we developed the v2 API within the v1 API, so name conflicts were possible during the transition. For prior precedence, the v1 "jsonpb" package has a Marshaler type that is effectively an options struct with actor methods hung off of it.

from protobuf.

puellanivis avatar puellanivis commented on June 2, 2024

As far as I understand, yeah, the type-alias wouldn’t introduce any overhead to performance or inlining. There’s already so much type aliasing in the standard library, that if it were a performance impact, then it should have been handled already.

from protobuf.

matttproud avatar matttproud commented on June 2, 2024

FWIW: I found the "options"-laden names confusing when studying the new API. I literally asked myself as I was reading the APIs: "Options, but for what? What's taking them?"

from protobuf.

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.