-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC Generate a prettyprinter for structs #203
Comments
I like this idea and spent a little time looking into a possible implementation. It unfortunately doesn't appear to be an easy thing to build, however. Because structs are just maps, the only want to determine which fields contain enums is based on matching against their names, and hooking into the I think that could be done somewhat generically and reused for each of our generated structs, but it's still a good amount of complexity. I think that work is roughly equivalent to rolling our own pretty printing function, so I'm not sure there's a benefit to not using |
This is a little off-the-walll, but in the Ruby thrift lib, enum values get printed out as their name, which can be pretty nice for debugging purposes. We could theoretically generate a
defimpl Inspect
for structs and have it do this. For the most part I think this would just hijack the normal struct implementation but it could replace the enum entries with something likeuser_status: 1 (UserStatus.active)
.OTOH it could be not worth the complexity. Something opt-in might be a compromise? I.e., the generated module could include a prettyprint function or something and then we provide docs showing how you could roll your own
defimpl
around that.The text was updated successfully, but these errors were encountered: