introduce tfHasOwned for fast must-move checkings; removed tfAcyclic as the GC has ignored this hint for quite some time now

This commit is contained in:
Andreas Rumpf 2019-03-05 17:29:48 +01:00
commit 4be36d77f6
9 changed files with 30 additions and 63 deletions

View file

@ -6925,41 +6925,8 @@ The ``noreturn`` pragma is used to mark a proc that never returns.
acyclic pragma
--------------
The ``acyclic`` pragma can be used for object types to mark them as acyclic
even though they seem to be cyclic. This is an **optimization** for the garbage
collector to not consider objects of this type as part of a cycle:
.. code-block:: nim
type
Node = ref NodeObj
NodeObj {.acyclic.} = object
left, right: Node
data: string
Or if we directly use a ref object:
.. code-block:: nim
type
Node = ref object {.acyclic.}
left, right: Node
data: string
In the example a tree structure is declared with the ``Node`` type. Note that
the type definition is recursive and the GC has to assume that objects of
this type may form a cyclic graph. The ``acyclic`` pragma passes the
information that this cannot happen to the GC. If the programmer uses the
``acyclic`` pragma for data types that are in reality cyclic, the GC may leak
memory, but nothing worse happens.
**Future directions**: The ``acyclic`` pragma may become a property of a
``ref`` type:
.. code-block:: nim
type
Node = acyclic ref NodeObj
NodeObj = object
left, right: Node
data: string
The ``acyclic`` pragma applies to type declarations. It is deprecated and
ignored.
final pragma