Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntactic sugar for Generics #1609

Open
achkasov opened this issue Feb 6, 2025 · 1 comment
Open

Syntactic sugar for Generics #1609

achkasov opened this issue Feb 6, 2025 · 1 comment

Comments

@achkasov
Copy link

achkasov commented Feb 6, 2025

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.

@alimpfard
Copy link
Member

🤔 I don't really see why this would be necessary tbh, you rarely need to name things like this and your scheme only saves one character...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants