Skip to content

Allow Plan 9/Go style struct embedding #1214

Closed
@isaachier

Description

@isaachier

GCC allows use of -fplan9-extensions to accomplish Go-style anonymous struct embedding. See more here. I believe this is a simple C concept (seeing as it was a Plan 9 C compiler extension), so does not conflict with the C-style simplicity of Zig, and adds some nice abstractions to structs for free. The main benefit: extending a struct is by and large unnecessary when the compiler let's you treat the parent struct like it was an instance of the embedded base class (Liskov substitution principle applies to parent structs).

One quick example, stdout often needs to be replaced with stdout.stream despite the fact the stdout is meant to implement a stream. This could simplify all uses of stdout.stream back to stdout.

Metadata

Metadata

Assignees

No one assigned

    Labels

    proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions