-
-
Notifications
You must be signed in to change notification settings - Fork 99
Implement =move and =sink operators (destructors) #150
Copy link
Copy link
Closed
Description
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.
=moveand=sinkpromise 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
Reactions are currently unavailable