Skip to content

Classfile variables #2514

@xushiwei

Description

@xushiwei

In XGo classfile T, the following code

var (
    name1 V1
    name2 V2
)

would be converted to:

type T struct {
    name1 V1
    name2 V2
}

And in previous versions of XGo, the following code

var (
    name1 V1
)

var (
    name2 V2
)

would be converted to:

type T struct {
    name1 V1
}

var (
    name2 V2
)

To avoid inconsistencies in the behavior of the first var block and other var blocks, we decide to prohibit defining multiple normal var blocks in the classfile.

If you need to define global variables in the classfile, you need to use static members:

var (
    name1 V1 // class member
)

var (
    .name2 V2 // static variable
)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions