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
This repository was archived by the owner on Jun 20, 2025. It is now read-only.
This repository was archived by the owner on Jun 20, 2025. It is now read-only.
Pass serializer into aggregate serialization interface methods #56
Open
@phan-computer

Description

@phan-computer

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0