Skip to content

Syntactic sugar for Generics #1609

Open
@achkasov

Description

I propose using \ as a simple syntactic sugar for generics with a single type parameter.

The two following types are equivalent:

Bar<T>
Bar\T

This might make nested types simpler avoiding the long >>>> tail, and look like a directory tree. A made up example with two equivalent types below

Ref<Box<RawPtr<T>>>
Ref\Box\RawPtr\T

The generics with several type parameters can be used as usual:

Box<Result<E<String>, RawPtr<Box<T>>>>
Box\Result<E\String, RawPtr\Box\T>

Any token can be used for the nesting, not necessarily \, the / could be used as well, as long as it does not introduce confusion.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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