fubark / cyber

Fast and concurrent scripting.
https://cyberscript.dev
MIT License
1.18k stars 40 forks source link

tuples: yes/no? semantics? #7

Open matu3ba opened 1 year ago

matu3ba commented 1 year ago

con:

pro

C structs compat.

fubark commented 1 year ago

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 commented 1 year ago

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