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

tuples: yes/no? semantics? #7

Open
matu3ba opened this issue Jan 20, 2023 · 2 comments
Open

tuples: yes/no? semantics? #7

matu3ba opened this issue Jan 20, 2023 · 2 comments

Comments

@matu3ba
Copy link

matu3ba commented Jan 20, 2023

con:

  • more stuff to keep track in meta-table
  • slowdown
  • untyped ones can be painful
  • more complex type system

pro

  • much nicer to use for grouping things
  • better than Python (tuples not allowed as function arguments)
  • once proper layouted, they allow function argument reordering for efficiency

C structs compat.

@fubark
Copy link
Owner

fubark commented Jan 20, 2023

Tuples are nice, they would be like strings except each element can be any value. I think it would be a nice addition but it's not a big priority. Currently, you can create a list with an initial capacity using arrayFill, but it's still mutable.

I'd like to know what people like using tuples for to further the case of supporting them. One use I can think of is using them as keys to a map. Another might be slicing like string slices.

If we did have them, I think the initializer might look like tuple = #[ 1, 2, 3, 'foo'].

@dumblob
Copy link

dumblob commented Jan 28, 2023

Tuples are usually used in embedded and/or tree-like structures a lot. Otherwise they are perceived as a poor man's "performance" solution to lack of immutability in various parts of the language (Cyber has only immutable strings, but lacks any other immutability).

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

3 participants