Skip to content
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

Use enif_term_type instead of enif_is_xyz when encoding #200

Closed
lpgauth opened this issue May 21, 2020 · 2 comments
Closed

Use enif_term_type instead of enif_is_xyz when encoding #200

lpgauth opened this issue May 21, 2020 · 2 comments

Comments

@lpgauth
Copy link
Contributor

lpgauth commented May 21, 2020

Form the OTP-22 changelog:

  • Added the NIF function enif_term_type, which helps avoid long sequences of enif_is_xyz by returning the type of the given term. This is especially helpful for NIFs that serialize terms, such as JSON encoders, where it can improve both performance and readability.
@davisp
Copy link
Owner

davisp commented May 21, 2020

Maybe in 5-6 years when 22 is old.

@davisp davisp closed this as completed May 21, 2020
@davisp
Copy link
Owner

davisp commented May 21, 2020

Oops. That was maybe more terse than I meant. For color, 23 has finally forced my hand to drop support for R14. Jiffy is small enough that I work on keeping it compatible with as many VM versions as possible.

That new API would be quite useful to add, but the complexity tradeoff if-def'ing around that wouldn't be worth it since we'd still have to maintain the if/else chain for type detection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants