Skip to content

Custom string representation #20

@martinfinke

Description

@martinfinke

Hi, thanks for this very interesting project!

Would it be possible to define a custom string for each enum value, instead of auto-generating it from the token? For example, instead of:

WISE_ENUM(Color, (GREEN, 2), RED)

You could write:

WISE_CUSTOM_ENUM(Color, (GREEN, "vert", 2), (RED, "rouge"))

(there's probably a better name than CUSTOM)

The main advantage for my use case: Let's say you use (GREEN, "GREEN") and the string is persistently stored in configuration files / XML / JSON etc. Later you rename the GREEN enum value in a refactor. This way it remains compatible with the old files because the string "GREEN" is independent. If you want, you can keep the old string, or decide to write custom code for backwards compatibility. But the compatibility doesn't break without notice.

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