Skip to content

Doc improvements #12

Description

@gshanemiller
  • point out in gotchas does not support enums
  • And on derserialization, better document how memory is managed. Suppose a type T is serialized. Further suppose T contains a slice of type []Foo, and that T has methods to add and remove items from Foo. Then during deserialization a slice of []Foo would have to be allocated separately so T's mutator methods can add/remove items to []Foo in memory for it alone

This latter issue is a problem with Zig's parseFromSlice JSON deserializer. Although it's darn flexible handling enums, the object is exists inside a (essentially) single allocation. Therefore, add/removing items from []Foo is no longer possible after deserialization. In short, a single allocation for T is fine provided T is never mutated after deserialization otherwise a more sophisticated deserialization method is need to allocate separate memory per field as needed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions