elixir-thrift icon indicating copy to clipboard operation
elixir-thrift copied to clipboard

Use atoms to represent enums

Open pguillory opened this issue 8 years ago • 2 comments

Previously, deserializing an enum value would yield an integer. Since you would not want to hard code these integers into your Elixir code, and because they're essentially unreadable, we generated macros/functions to convert back and forth between enum names and values.

With this commit, enum values are deserialized as atoms, which is more idiomatic and people should generally be able to work with directly.

We still generate the macros, which should provide some backwards compatibility. They generate a deprecation warning when used. At some point in the future we should remove them completely.

The atoms used match the enum definitions exactly. We no longer need to worry about manipulating the case and adding underscores to generate valid Elixir identifiers.

Closes #312.

pguillory avatar Jan 09 '18 16:01 pguillory

This would be a breaking change for me. I commented on #312. Sorry I missed the issue when you originally posted it :/

dantswain avatar Jan 09 '18 16:01 dantswain

@dantswain No problem, I didn't wait long before putting up code but there's no rush.

pguillory avatar Jan 09 '18 17:01 pguillory