Skip to content

Add writeValue/readValue to std and pkg serializers#25

Draft
nitely wants to merge 2 commits into
mainfrom
pkg_std_no_defaults
Draft

Add writeValue/readValue to std and pkg serializers#25
nitely wants to merge 2 commits into
mainfrom
pkg_std_no_defaults

Conversation

@nitely
Copy link
Copy Markdown
Collaborator

@nitely nitely commented Feb 21, 2026

Currently, if the user does defaultSerialization(flavor, T) where T is a type in std/pkg modules, and they forget to actually import such module (or remove the import later by mistake), the default serialization will use the object one (if T is an object), which if lucky will throw a comptime error (or worse it will serialize the value giving an incorrect encoded output). This PR fixes this by not making defaultSerialization needed for std/pkg modules.

The write* and read* procs are still needed when the flavor/format has defaultSerialization(flavor, object), so the generated code will call these functions, as the generated readValue/writeValue match harder than the readValue/writeValue this PR adds.

Changes:

  • Add writeValue and readValue to the std and pkg modules. This makes it so defaultSerialization is no longer needed to enable these.

This seems backward compatible.

Edit: the problem is really defaultSerialization(flavor, object) which enables a default serialization for any object, maybe the solution is for flavors to not enable it which is already the case in usage I've seen... and the current behavior makes sense... it could just be documented... mmh

Edit2: a different way of solving this is to add an additional defaultSerialization that accepts a module name, and then calls module.write/read. Alternatively, add a extensionSerialization that calls some alias for read/write defined in std/pkg modules. Either is an addition non-breaking change.

Ref #2

@nitely nitely changed the title writeValue/readValue in std and pkg serializers Add writeValue/readValue to std and pkg serializers Feb 21, 2026
@nitely nitely marked this pull request as ready for review February 21, 2026 09:18
@nitely nitely marked this pull request as draft March 8, 2026 03:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant