8000 Pass serializer into aggregate serialization interface methods · Issue #56 · getty-zig/getty · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Pass serializer into aggregate serialization interface methods #56

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

Open
ibokuri opened this issue Dec 23, 2022 · 0 comments
Open

Pass serializer into aggregate serialization interface methods #56

ibokuri opened this issue Dec 23, 2022 · 0 comments
Labels
proposal This issue suggests modifications. If it also has the "accepted" label then it is planned.
Milestone

Comments

@ibokuri
Copy link
Contributor
ibokuri commented Dec 23, 2022

Problem

The proposal in #55 got me thinking.

In Getty JSON, the implementation for the aggregate serialization interfaces (e.g., getty.ser.Seq, getty.ser.Map) has a field referencing the serializer passed to serializeSeq, serializeStruct, etc. I believe the field is used in every single one of the aggregate interface methods (no surprise there; most of them are literally called serializeX).

But having to carry this field around in the implementation isn't ideal. Any SB that calls serializeSeq already has a reference to the same serializer, so there's no need to store it in the implementation. Also, it makes more sense to have the serializer as a parameter of the methods doing the serialization than on the impl itself.

Proposal

So, what if we pass in the serializer to the methods like serializeElement, serializeKey, and so on? The SB calling serializeStruct would always have a reference to the relevant serializer so it'd be easy to pass it in for them.

This would simplify implementations of the aggregate interfaces since they'd no longer need to keep a redundant serializer around.

Alternatives

No response

Additional Context

No response

@ibokuri ibokuri added the proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. label Dec 23, 2022
@ibokuri ibokuri added this to the 0.3.0 milestone Dec 23, 2022
@ibokuri ibokuri modified the milestones: 0.3.0, 0.5.0 Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal This issue suggests modifications. If it also has the "accepted" label then it is planned.
Projects
None yet
Development

No branches or pull requests

1 participant
0