Skip to content

Implement =move and =sink operators (destructors) #150

@mratsim

Description

@mratsim

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).

Related issues memory allocation: #46, #141, #23, #19, #104, #89, #121

Edit, support is opt-in via the new compilation flag --newruntime

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions