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

Explicit nested struct serialization options #1050

Open
Gusarich opened this issue Nov 17, 2024 · 0 comments
Open

Explicit nested struct serialization options #1050

Gusarich opened this issue Nov 17, 2024 · 0 comments
Labels
discussion Ideas that are not fully formed and require discussion language feature

Comments

@Gusarich
Copy link
Member

Currently, the compiler automatically determines whether to serialize a nested struct inlined in the same cell or as a reference, based on whether it fits. This proposal introduces a way for developers to explicitly specify the desired serialization mode.

For example:

struct B {
    c: Int;
    d: Int;
}

struct A {
    a: Int;
    b: Int;
    c: B as inline;  // Always inline
    d: B as ref;     // Always reference
}

With this feature:

  • c will always be serialized in the same cell as A, while
  • d will always be serialized as a reference, regardless of their sizes.

If the specified serialization mode is not feasible (e.g., a large struct is forced as inline but cannot fit in the cell), the compiler will throw a compilation error.

@Gusarich Gusarich added discussion Ideas that are not fully formed and require discussion language feature labels Nov 17, 2024
@Gusarich Gusarich changed the title Explicit nested struct serialization Explicit nested struct serialization options Nov 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Ideas that are not fully formed and require discussion language feature
Projects
None yet
Development

No branches or pull requests

1 participant