Open TimWhiting opened 3 weeks ago
We might want to add a few more apis (cutting an array short and dropping the the rest of the array), or extending an array.
We might want to add a few more apis (cutting an array short and dropping the the rest of the array), or extending an array.
Yes, that would be fun! I think we could also support vector.filter
, which would require us to write box_null
into the tail of the vector and keep a separate length field. In OCaml, this is unsupported since box_null
might not be an inhabitant of the type of the elements though, and I wonder if there is a problem that I don't see currently.
We might want to add a few more apis (cutting an array short and dropping the the rest of the array), or extending an array.
Yes, that would be fun! I think we could also support
vector.filter
, which would require us to writebox_null
into the tail of the vector and keep a separate length field. In OCaml, this is unsupported sincebox_null
might not be an inhabitant of the type of the elements though, and I wonder if there is a problem that I don't see currently.
I think these sorts of APIs are maybe best left to a resizeable vector type, which could hold on to the length like you mention and have a resize policy for add / extending the vector as well. What do you think?
Addresses #544
@anfelor can you take a look at this?
I added a few public apis and a few private helpers. Public:
set
update
update
for local variable vectorsThe most important function is the
copy
function, which ensures that the vector is unique prior to applying any mutation operations. For many cases we would expect it to be unique.