Skip to content

API design suggestion: rename UnmarshalOptions to Unmarshaler #1586

Open
@stapelberg

Description

@stapelberg

Capturing this suggestion from @matttproud over in matttproud/golang_protobuf_extensions#22:

As a comment on the modern Protocol Buffer API, I find it rather strange that a type with "options" in the name does some imperative action versus being just configuration (e.g., an option/configuration struct/container). I could see taking protodelim.UnmarshalOptions and naming it protodelim.Unmarshaler or protodelim.Decoder. It's totally normal for types to accept configuration parameters directly, in which case having those fields in either of those two names would make sense. But seeing "options" makes it confusing, because few people would expect a type named "options" to be the meat of the business logic.

Seems like a reasonable change to me on first glance.

We should verify that type aliases like type protodelim.UnmarshalOptions = protodelim.Unmarshaler don’t have any adverse effects on performance/inlining (probably fine).

We should also do a quick survey to see how widely used the Options types are, and then judge the churn against the benefit.

Filing this here for now to give folks a chance to chime in.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions