Skip to content

Feature Request: go-like struct composition with splatting syntax? #42777

@Borketh

Description

@Borketh

The Go language has this cool feature for struct composition where if you put one struct after another's values, its values are inherited into the other.

type foo1 struct {
    bar   string
}
type foo2 struct {
    baz   string
    foo1  // foo2 now also has the field "bar" inherited from foo1
}

This seems like it would fit well into Julia.

My suggested implementation would be:

struct foo1
    bar::String
end

struct foo2
    baz::String
    foo1...
end

Thanks for taking the time to read this! It would be yet another pretty nifty trick that Julia could use.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureIndicates new feature / enhancement requests

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions