It’s a little surprising to see SERIALIZE_METHODS depend on FORMATTER_METHODS, but I guess it saves some repetition, and it seems reasonable
I think it makes sense: every class gets the ability to function as a formatter. Both FORMATTER_METHODS and SERIALIZE_METHODS help do that; with the first it’s for an arbitrary type, with the latter it’s for objects of the class it’s being defined it. The latter then also hooks up the Serialize/Unserialize functions to the self-formatter.
I think it’s fine. A formatter class with a formatter methods is a class that can serialize and deserialize objects in a particular format. A serializable type with serialize methods is a class whose instances can serialize and deserialize themselves. I wasn’t expecting serializeable objects to now be able to format other objects of the same type, and I couldn’t think of a use for that, but I think it’s harmless.
Do you suggest documenting this better, or have some other suggestion?
I guess the suggestion would be to keep the new FORMATTER_METHODS macro exactly like you have it here, but revert the changes to the SERIALIZE_METHODS macro, so it isn’t affected by this PR. But only if you want to have a stronger distinction between formatter classes and serializable types. I’m fine either way.