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
This might be a useful hack, at least in the short term.
For example, in Scheme, (write-bytevector vec port) needs to call writer.write(buf) on some buffer. But it's unsafe to create a reference to the actual buffer in vec, because the vector has interior mutability: it could be aliased, and all aliases have write access.
As a hack, write-bytevector could momentarily swap the buffer out of the in-heap Vec, so that it "owns" the buffer and can safely pass it to .write(). The in-heap Vec would be momentarily empty. On success or failure, write-bytevector would swap the buffer back into the heap. Hokey but at least it's not a copy.
The text was updated successfully, but these errors were encountered:
This might be a useful hack, at least in the short term.
For example, in Scheme,
(write-bytevector vec port)
needs to callwriter.write(buf)
on some buffer. But it's unsafe to create a reference to the actual buffer invec
, because the vector has interior mutability: it could be aliased, and all aliases have write access.As a hack,
write-bytevector
could momentarily swap the buffer out of the in-heapVec
, so that it "owns" the buffer and can safely pass it to.write()
. The in-heapVec
would be momentarily empty. On success or failure,write-bytevector
would swap the buffer back into the heap. Hokey but at least it's not a copy.The text was updated successfully, but these errors were encountered: