-
Notifications
You must be signed in to change notification settings - Fork 131
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
[Feature Request] Introduce Visibility to Struct #157
Comments
Definitely has been on our radar! If/when this happens, private structs would likely happen first, with field visibility coming later |
Is the idea here that external modules can still see private structs (e.g., include |
I prefer that external modules can not see a private struct, and can not |
I'll be a bit more concrete about how the rule for private structs would shake out.
So to @sblackshear's question, I don't think there would be any seeing of private structs in other modules. But things are different if we ever get to private/public fields. In a way, what we have today is all public structs and all private fields. So much like Rust, I would be in favor of exposing borrowing on public fields, AND exposing pack/unpack on a public struct if ALL fields are public. |
The strongest motivation I can see for private structs (or a feature like it) is the ability to use For example, there's been a lot of debate about whether the bytecode language should include
, where Similarly, Sui has some native operations like |
Yes, as I mention in #158, the |
If the type is |
🚀 Feature Request
Motivation
Currently, Move's structs use implicit visibility, e.g.
is equivalent to.
Also, an implicit global storage access restriction is used to ensure that a struct can only be borrowed in the module in which it is defined.
This is actually equivalent to a conditional visibility constraint and has the same effect as adding a private visibility constraint to the struct.
So I propose to introduce the visibility of structs. This leaves it up to the smart contract developer to decide on access control for the global storage and the struct fields.
For example.
Of course, compatibility is a bigger problem, this is just an idea. If it works, I can do more work on it.
The text was updated successfully, but these errors were encountered: