You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note 1: All references in this proposal are after the changes in the above PR (e.g., end is exclusive).
Note 2: For those not familiar with it, Packed arrays are implemented as Vector internally, so whenever I say Vector I am referring to Packed*Array.
Describe the problem or limitation you are having in your project
Array.slice and Vector.slice behave differently
Array takes begin, end, step, deep, Vector takes only begin and end.
Array will never error unless step is invalid, while Vector fails if the indices are not -size() <= i < size().
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Remove step.
All indices out of bounds will error: 0 <= i < size(), with the exception of -1 for end. I think this makes sense because:
a) I find it unlikely that someone will pass -2 to mean the second to the last element, since that's kind of oddly specific.
b) This way there can be a default value of -1.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Describe the project you are working on
godotengine/godot#35901
Note 1: All references in this proposal are after the changes in the above PR (e.g.,
end
is exclusive).Note 2: For those not familiar with it, Packed arrays are implemented as
Vector
internally, so whenever I sayVector
I am referring toPacked*Array
.Describe the problem or limitation you are having in your project
Array.slice and Vector.slice behave differently
Array
takesbegin
,end
,step
,deep
,Vector
takes onlybegin
andend
.Array
will never error unlessstep
is invalid, whileVector
fails if the indices are not-size() <= i < size()
.Describe the feature / enhancement and how it helps to overcome the problem or limitation
step
.0 <= i < size()
, with the exception of-1
forend
. I think this makes sense because:a) I find it unlikely that someone will pass
-2
to mean the second to the last element, since that's kind of oddly specific.b) This way there can be a default value of
-1
.Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
If this enhancement will not be used often, can it be worked around with a few lines of script?
Array and Vector are used often.
Is there a reason why this should be core and not an add-on in the asset library?
Array and Vector are part of core.
The text was updated successfully, but these errors were encountered: