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

support * in tuples #1791

Open
HoneyryderChuck opened this issue Apr 5, 2024 · 3 comments
Open

support * in tuples #1791

HoneyryderChuck opened this issue Apr 5, 2024 · 3 comments
Labels
enhancement New feature or request spec

Comments

@HoneyryderChuck
Copy link
Contributor

I've found that I can't type a certain type of code I maintain, where it'd make sense to do so.

operation = ["+"]
operation << 1
operation << 2

I'd like to type this as a tuple of a given type at the head, and variable values of same type at the tail, smth like operation: [String, *Integer], but the parser does not support that.

@soutaro
Copy link
Member

soutaro commented Apr 6, 2024

I understand the motivation. The extension itself looks reasonable, but I'm afraid if further extension is required? Like [String, *Integer, Symbol] or [*Integer, String, *bool].

Do you think having one * types at the end of tuple makes enough sense?

@soutaro
Copy link
Member

soutaro commented Apr 6, 2024

tuple_type ::= `[` _type_ `,` ... `,` _type_ `]`        # Closed tuple
             | `[` _type_` `,` ... `,` `*` _type_ `]`   # Open tuple

@soutaro soutaro added enhancement New feature or request spec labels Apr 6, 2024
@HoneyryderChuck
Copy link
Contributor Author

I'd follow the ruby rule here, and only allow * at the end, and once. Allows for a simpler implementation perhaps, and you can always consider extensions later on based on demand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request spec
Development

No branches or pull requests

2 participants