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

Table tuples #1584

Closed
Vurv78 opened this issue Dec 21, 2024 · 1 comment
Closed

Table tuples #1584

Vurv78 opened this issue Dec 21, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@Vurv78
Copy link

Vurv78 commented Dec 21, 2024

I've looked everywhere and I cannot seem to find any indication that tuples, or typed numeric table indices, exist.

Usually when documentation here refers to tuples it's in reference to multiple return values, but I'm referring to

local tuple = { 1, "foo", true }

For Emmylua/LuaLS, you'd type this as

---@type { [1]: number, [2]: string, [3]: boolean }

Such syntax almost exists in Luau?

type Tuple = { ["foo"]: number }

But providing a number instead of a string in the brackets gives a syntax error.

In typescript you'd do

type Tuple = [number, string, boolean]

But that syntax doesn't exist in Luau either. Nor does (number, string, boolean), or {number, string, boolean} (which would be nearly ambiguous with arrays.)

This is partially a question - partially to see if I need to continue this with an RFC. It would be nice to use tuples for simpler types like Spans instead of needing full field names. And I don't think the implementation would be very difficult considering the precedent with the existing syntax for strings I demonstrated.

@Vurv78 Vurv78 added the enhancement New feature or request label Dec 21, 2024
@vegorov-rbx
Copy link
Collaborator

This feature is not supported in Luau.
We do not accept language feature requests as 'enhancement' issues.

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

No branches or pull requests

3 participants
@Vurv78 @vegorov-rbx and others