Updated NEP 2 Catching up with C and Rust: Ownership, destructors, unique pointers (markdown)

This commit is contained in:
Arne Döring 2016-09-27 19:23:09 +02:00
parent 1ccb39e3cf
commit 802e928737
1 changed files with 7 additions and 0 deletions

View File

@ -50,5 +50,12 @@ proc `=`(dst: var MyType; src: MyType) =
dst.resources = src
```
I just heard, that self assignment on types that have deinitialization would not work anymore. This can be handled by implementing some logic that checks weather it is selft assignment, or by simply declaring self assignment illegal. One version that works with self assignment is the following (again in psoudocode), but it still needs to explain what move semantics are.
```Nim
proc `=`(dst: var MyType; src: MyType) =
tmp <- copy(src)
destroy(dst)
dst <- tmp
```