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

Define ei version number in ei.h #9026

Closed
siiky opened this issue Nov 6, 2024 · 3 comments
Closed

Define ei version number in ei.h #9026

siiky opened this issue Nov 6, 2024 · 3 comments
Assignees
Labels
enhancement team:VM Assigned to OTP team VM

Comments

@siiky
Copy link
Contributor

siiky commented Nov 6, 2024

Is your feature request related to a problem? Please describe.

Related to this thread. When I learned of ei I tried my hand at implementing a wrapper in my go-to Scheme implementation, and noticed that ei_get_type() returns the ei version number for a full encoded Erlang term. However, because the version is not defined in ei.h, I have to guess that that is the version and not an unknown type.

Describe the solution you'd like

It appears to me that ERL_VERSION_MAGIC could be moved to somewhere around here.

If this is totally intentional and there's a reason for the version not to be publicly defined (maybe I'm holding it wrong?), I would also like to know -- maybe the docs are lacking in some way in that case.

Describe alternatives you've considered

As a temporary workaround, I've defined the version number in the wrapper library. This is not ideal, in case the version changes, although it's also not worrying since the last change was ~15 years ago ^^

@jhogberg jhogberg self-assigned this Nov 6, 2024
@jhogberg
Copy link
Contributor

jhogberg commented Nov 6, 2024

I suspect that you're using it wrong, the first part of an encoded term is a version that must be decoded with ei_decode_version first.

That ei_get_type returns the first encountered byte is a bit of an accident, I think it should signal failure (-1) instead when encountering a type it does not recognize.

@IngelaAndin IngelaAndin added the team:VM Assigned to OTP team VM label Nov 6, 2024
@siiky
Copy link
Contributor Author

siiky commented Nov 7, 2024

I suspect that you're using it wrong

I wouldn't be surprised, and as long as I learn how to use it correctly, I don't mind. So my thought process previously was to ei_get_type() and then call the corresponding ei_decode_*(). You're saying one should instead call ei_decode_version() before any other ei_get_type()/ei_decode_*(). Is that the intended usage of the library?

@jhogberg
Copy link
Contributor

jhogberg commented Nov 7, 2024

You're saying one should instead call ei_decode_version() before any other ei_get_type()/ei_decode_*(). Is that the intended usage of the library?

Yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement team:VM Assigned to OTP team VM
Projects
None yet
Development

No branches or pull requests

3 participants