Skip to content

Custom types for dumps() #94

@mdbenito

Description

@mdbenito

As far as I can tell, currently the only branch in udump() that allows serialization of custom types goes through TaggedElement. One must subclass this and implement __str__(). IMO this is problematic for two reasons:

  1. One may not control the class definition at all so that subclassing is not an option.
  2. Using __str__ for EDN serialization might be undesirable. Very often one wants simpler representations for debugging from this method.
  3. It is not always the case that a custom type must be tagged. One can of course just not return any, but that makes the semantics of TaggedElement confusing.

I think all of these can be overcome by allowing registering custom handlers for arbitrary types, exactly in the same manner that @tag does. These would be based on type instead of string. One could add some syntactic sugar with a decorator as well.

Or is there some other way I missed?

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