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
Move operator =move (for a and b being var T) and =sink (for a being var T and b being T) were introduced in master and are described in Araq's pointer-free programming blog post.
Using those should allow value semantics i.e. let a = b; a[1] = 0 does not change the value of b[1] with the efficiency of reference semantics i.e. every slice, =, reshape is a view of the same data.
Value semantics is safe but makes it easy to trigger useless memory allocation.
Reference semantics is fast but makes it easy to shoot yourself in the foot.
=move and =sink promise the best of both world with the compiler autodetecting when it's safe to move (reference semantics) or copy (value semantics).
This also would have the tremendous benefits of making "unsafe" proc much less mandatory for general users. (They would still be used inside Arraymancer to mutate slices for example).
mratsim
changed the title
Use =move and =sink operator for no-copy value semantics (destructors)
Implement =move and =sink operators (destructors)
Nov 26, 2017
Move operator
=move
(for a and b being var T) and=sink
(for a being var T and b being T) were introduced in master and are described in Araq's pointer-free programming blog post.Using those should allow value semantics i.e.
let a = b; a[1] = 0
does not change the value ofb[1]
with the efficiency of reference semantics i.e. every slice,=
,reshape
is a view of the same data.=move
and=sink
promise the best of both world with the compiler autodetecting when it's safe to move (reference semantics) or copy (value semantics).This also would have the tremendous benefits of making "unsafe" proc much less mandatory for general users. (They would still be used inside Arraymancer to mutate slices for example).
Related issues memory allocation: #46, #141, #23, #19, #104, #89, #121
Edit, support is opt-in via the new compilation flag
--newruntime
The text was updated successfully, but these errors were encountered: