Add typed tuples to GDScript
### Describe the project you are working on No projects at the moment due to life being an asshole, worked on some small projects before. ### Describe the problem or limitation you are having in your project The upcoming Typed Array doesn't have a case for tuples (fixed length, heterogeneous arrays). ### Describe the feature / enhancement and how it helps to overcome the problem or limitation Tuples would be a type alias for arrays. They have fixed-length and heterogeneous types, like in Python or Typescript. Technically, this would mean adding a type alias, (I think this is easy) and adding special cases for it (error on length manipulation, error on random access, ...). ### Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams ```gdscript var tuple_variable: Tuple[int, Node2D, String] = [17, some_node2d_var, "str"] tuple_variable[0] = 15 tuple_variable[1] = 15 # fails var invalid = tuple_variable[some_idx_var] # it can fail at compile time (safer) # or it can fail at run time if the index is out of bounds tuple_variable.append(5) # fails, tuples have fixed length func smal_tuple_func(arg: Tuple[int, Node2D]): ... func big_tuple_func(arg: Tuple[int, Node2D, String, int]): ... smal_tuple_func(tuple_variable) # works, last value is omited big_tuple_func(tuple_variable) # fails, last value is missing ``` ### If this enhancement will not be used often, can it be worked around with a few
Posted by FelipeSharkao on Jul 2, 2021, 1:09 PM
Tags
Related issues
- The issue is really the extreme difficulty of programming them, especially for anything sequential (rather than combinatorial).
- I probably could have beared with it if it was only limited to programming, but it showing up in creative fields has made me feel all sor...
- I hate that I'm in deep enough to know what you mean.
- The biggest problem with “AI” is that big corps are shoving it down our throats.
- in the middel of a coding session with 5.6 sol.
- [Hero Run] 535B-A23B on 18T tokens
Raise real-world problems, find people facing the same issue, and discuss solutions.3,000 issues0 comments
reliability (Other)
The issue is really the extreme difficulty of programming them, especially for anything sequential (rather than combinatorial).
I probably could have beared with it if it was only limited to programming, but it showing up in creative fields has made me feel all sor...
I hate that I'm in deep enough to know what you mean.
The biggest problem with “AI” is that big corps are shoving it down our throats.
in the middel of a coding session with 5.6 sol.
[Hero Run] 535B-A23B on 18T tokens
I hate that this is how AI is being used..
inexperienced protobuf user here -- why do non-googlers generally use protobuf?
Add typed tuples to GDScript
### Describe the project you are working on No projects at the moment due to life being an asshole, worked on some small projects before. ### Describe the problem or limitation you are having in your project The upcoming Typed Array doesn't have a case for tuples (fixed length, heterogeneous arrays). ### Describe the feature / enhancement and how it helps to overcome the problem or limitation Tuples would be a type alias for arrays. They have fixed-length and heterogeneous types, like in Python or Typescript. Technically, this would mean adding a type alias, (I think this is easy) and adding special cases for it (error on length manipulation, error on random access, ...). ### Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams ```gdscript var tuple_variable: Tuple[int, Node2D, String] = [17, some_node2d_var, "str"] tuple_variable[0] = 15 tuple_variable[1] = 15 # fails var invalid = tuple_variable[some_idx_var] # it can fail at compile time (safer) # or it can fail at run time if the index is out of bounds tuple_variable.append(5) # fails, tuples have fixed length func smal_tuple_func(arg: Tuple[int, Node2D]): ... func big_tuple_func(arg: Tuple[int, Node2D, String, int]): ... smal_tuple_func(tuple_variable) # works, last value is omited big_tuple_func(tuple_variable) # fails, last value is missing ``` ### If this enhancement will not be used often, can it be worked around with a few
Comments (0)
No comments yet. Start the discussion.