-
Notifications
You must be signed in to change notification settings - Fork 11
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
[WIP] auto generate public values structure and index #357
base: master
Are you sure you want to change the base?
Conversation
a26ae9c
to
e54c81d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like what you are trying to do, but there's much simpler ways to achieve the same result.
You can use repr(C)
to make sure that your struct and slice have the same memory layout. See #475 for how that can look like.
That way you don't need getters and setters, but can use a struct (and even nested structs) with named fields that rust-analyzer etc understand.
i feel this is outdated and can be closed? |
i usually do not do this in our use cases. This is like mixing hardware encoding and business encoding. It is like we don't use protobuf for eth protocol wire encoding. repr(C) like idea relates to programming language, compiler, cpu, os. (for example, i remember C or C++ support non-8-bit-byte?). Fully writing your encoding inside codes explicitly means fully portable readable stable. |
I will make it as draft first (need to resolve conflict), for this PR still matter to address possible future bug, just not very urgent :) After we are clear for how to set public input, then we can go back to review this PR |
In principle you would be right, but in Rust See the docs
In any case, #475 is a better implementation of a similar idea. And without the Java-insipired getter-setter-hell. We can port the technique to other structs instead of |
This PR resolve possible tech debt in the future which defines public value index against the struct in different place, which might lead to potential mismatch.
A getter/setter/index are all generate via rust macro