Skip to content

Reconsider struct initialization syntax #202

Closed as not planned
Closed as not planned
@lolbinarycat

Description

@lolbinarycat

In Rust (which vine takes significant syntax inspiration from), the token : is used for two things:

  • Giving types to things
  • Initialization of structs

With 10+ years of hindsight, I think we can pretty definitively conclude this is a mistake.
The biggest problem is how this interferes with the type ascription,
so much so that type ascription as a feature was scrapped.

Another point of reference is Carbon, a language that also takes a lot of syntax inspiration from Rust, does not use : in struct literals.

This allows it to have more natural type ascription, which is especially noticeable for things like tuples.

Rust: let (x, y): (u8, u32) = (1, 2)

Carbon: let (x: u8, y: u32) = (1, 2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions