mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
cleanup ARC documentation (#15100)
This commit is contained in:
@@ -146,8 +146,6 @@ Advanced options:
|
||||
--legacy:$2
|
||||
enable obsolete/legacy language feature
|
||||
--useVersion:1.0 emulate Nim version X of the Nim compiler
|
||||
--newruntime use an alternative runtime that uses destructors
|
||||
and that uses a shared heap via -d:useMalloc
|
||||
--profiler:on|off enable profiling; requires `import nimprof`, and
|
||||
works better with `--stackTrace:on`
|
||||
see also https://nim-lang.github.io/Nim/estp.html
|
||||
|
||||
@@ -534,48 +534,6 @@ indirections:
|
||||
useItAgain(v)
|
||||
|
||||
|
||||
|
||||
Owned refs
|
||||
==========
|
||||
|
||||
**Note**: The ``owned`` type constructor is only available with
|
||||
the ``--newruntime`` compiler switch and is experimental.
|
||||
|
||||
|
||||
Let ``W`` be an ``owned ref`` type. Conceptually its hooks look like:
|
||||
|
||||
.. code-block:: nim
|
||||
|
||||
proc `=destroy`(x: var W) =
|
||||
if x != nil:
|
||||
assert x.refcount == 0, "dangling unowned pointers exist!"
|
||||
`=destroy`(x[])
|
||||
|
||||
proc `=`(x: var W; y: W) {.error: "owned refs can only be moved".}
|
||||
|
||||
proc `=sink`(x: var W; y: W) =
|
||||
`=destroy`(x)
|
||||
bitwiseCopy x, y # raw pointer copy
|
||||
|
||||
|
||||
Let ``U`` be an unowned ``ref`` type. Conceptually its hooks look like:
|
||||
|
||||
.. code-block:: nim
|
||||
|
||||
proc `=destroy`(x: var U) =
|
||||
if x != nil:
|
||||
dec x.refcount
|
||||
|
||||
proc `=`(x: var U; y: U) =
|
||||
# Note: No need to check for self-assignments here.
|
||||
if y != nil: inc y.refcount
|
||||
if x != nil: dec x.refcount
|
||||
bitwiseCopy x, y # raw pointer copy
|
||||
|
||||
proc `=sink`(x: var U, y: U) {.error.}
|
||||
# Note: Moves are not available.
|
||||
|
||||
|
||||
Hook lifting
|
||||
============
|
||||
|
||||
|
||||
Reference in New Issue
Block a user