Closed jonathanhogg closed 7 months ago
A possible down-side of this might be if I slice a vector anywhere and expect that a short vector will be honoured.
Seems like the best idea is to try this in a branch and test all of my existing code to see if any breaks…
Note that indexing null
is still going to have to return null
.
Initial tests with draft PR show that it seems to work fine.
Actually, on that "expanding out a vector note", you could force any vector to be a specific size with a range. So if radius
needs to be 3 items long, then a simple radius[..3]
would accomplish that. Most of the time this wouldn't be necessary, but it'd be handy when using functions like hypot()
. So hypot(SIZE[..2])
would give the diagonal length of a SIZE
rectangle even if SIZE
is a single value (i.e., a square).
There is an argument that indexing should wrap the same way that vector expansion in operators works, i.e., indices are modulo the length of the vector.
This would have a few benefits:
(1;1;1)
) would just worklen()
and do a subtraction5[..100]
would produce a hundred long vector all consisting of the number 5Question: should multi-binding
let
statements also wrap a short vector or should they match the behaviour of a multi-bindingfor
loop? It would seem to be useful if they did wrap, as then one could write:and have it do The Right Thing without having to do
SIZE * (1;1)
.This feels like it would be a substantive enough change that I should do it before 1.0.0 or not do it at all.