cyber icon indicating copy to clipboard operation
cyber copied to clipboard

tuples: yes/no? semantics?

Open matu3ba opened this issue 2 years ago • 2 comments

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.

matu3ba avatar Jan 20 '23 14:01 matu3ba

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'].

fubark avatar Jan 20 '23 16:01 fubark

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).

dumblob avatar Jan 28 '23 22:01 dumblob