Re:a[low:high:max] in Golang – A Rare Slice Trick
by morelisp on Saturday March 18, 2023 @07:48PM
(#35214410)
ArrayBuffers have a byteLength and a maxByteLength and this is similar to Go's len and cap, with the `resize()` being equivalent to a reslice or append on the subview.
[ Parent
| on HN ]
Re:a[low:high:max] in Golang – A Rare Slice Trick
by iainmerrick on Saturday March 18, 2023 @08:24PM
(#35214633)
The difference is that those operations are on the root ArrayBuffer in JS, not the TypedArray views on that buffer.
In Go, the underlying array is fixed, and each slice independently has resize/reallocate operations.
The JS approach seems better and more comprehensible to me. (I note also that MDN lists “resizable” and “maxByteLength” as new experimental features.)