Skip to content

Commit 342b74e

Browse files
authored
move type operation section and remove deepcopy document (#19389)
ref #19173; because deepcopy is not fit for ORC/ARC which was used for spawn and spawn will be removed from compiler
1 parent 7bdfeb7 commit 342b74e

File tree

2 files changed

+26
-40
lines changed

2 files changed

+26
-40
lines changed

doc/manual.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3902,6 +3902,18 @@ the operator is in scope (including if it is private).
39023902
Type bound operators are:
39033903
`=destroy`, `=copy`, `=sink`, `=trace`, `=deepcopy`.
39043904

3905+
These operations can be *overridden* instead of *overloaded*. This means that
3906+
the implementation is automatically lifted to structured types. For instance,
3907+
if the type `T` has an overridden assignment operator `=`, this operator is
3908+
also used for assignments of the type `seq[T]`.
3909+
3910+
Since these operations are bound to a type, they have to be bound to a
3911+
nominal type for reasons of simplicity of implementation; this means an
3912+
overridden `deepCopy` for `ref T` is really bound to `T` and not to `ref T`.
3913+
This also means that one cannot override `deepCopy` for both `ptr T` and
3914+
`ref T` at the same time, instead a distinct or object helper type has to be
3915+
used for one pointer type.
3916+
39053917
For more details on some of those procs, see
39063918
`Lifetime-tracking hooks <destructors.html#lifetimeminustracking-hooks>`_.
39073919

doc/manual_experimental.rst

Lines changed: 14 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,51 +1192,25 @@ object inheritance syntax involving the `of` keyword:
11921192
the `vtptr` magic produced types bound to `ptr` types.
11931193

11941194

1195-
Type bound operations
1196-
=====================
1197-
1198-
There are 4 operations that are bound to a type:
1199-
1200-
1. Assignment
1201-
2. Moves
1202-
3. Destruction
1203-
4. Deep copying for communication between threads
1204-
1205-
These operations can be *overridden* instead of *overloaded*. This means that
1206-
the implementation is automatically lifted to structured types. For instance,
1207-
if the type `T` has an overridden assignment operator `=`, this operator is
1208-
also used for assignments of the type `seq[T]`.
1209-
1210-
Since these operations are bound to a type, they have to be bound to a
1211-
nominal type for reasons of simplicity of implementation; this means an
1212-
overridden `deepCopy` for `ref T` is really bound to `T` and not to `ref T`.
1213-
This also means that one cannot override `deepCopy` for both `ptr T` and
1214-
`ref T` at the same time, instead a distinct or object helper type has to be
1215-
used for one pointer type.
1216-
1217-
Assignments, moves and destruction are specified in
1218-
the `destructors <destructors.html>`_ document.
1219-
1220-
1221-
deepCopy
1222-
--------
1223-
1224-
`=deepCopy` is a builtin that is invoked whenever data is passed to
1225-
a `spawn`'ed proc to ensure memory safety. The programmer can override its
1226-
behaviour for a specific `ref` or `ptr` type `T`. (Later versions of the
1227-
language may weaken this restriction.)
1195+
..
1196+
deepCopy
1197+
--------
1198+
`=deepCopy` is a builtin that is invoked whenever data is passed to
1199+
a `spawn`'ed proc to ensure memory safety. The programmer can override its
1200+
behaviour for a specific `ref` or `ptr` type `T`. (Later versions of the
1201+
language may weaken this restriction.)
12281202
1229-
The signature has to be:
1203+
The signature has to be:
12301204

1231-
.. code-block:: nim
1205+
.. code-block:: nim
12321206
1233-
proc `=deepCopy`(x: T): T
1207+
proc `=deepCopy`(x: T): T
12341208
1235-
This mechanism will be used by most data structures that support shared memory,
1236-
like channels, to implement thread safe automatic memory management.
1209+
This mechanism will be used by most data structures that support shared memory,
1210+
like channels, to implement thread safe automatic memory management.
12371211

1238-
The builtin `deepCopy` can even clone closures and their environments. See
1239-
the documentation of `spawn <#parallel-amp-spawn-spawn-statement>`_ for details.
1212+
The builtin `deepCopy` can even clone closures and their environments. See
1213+
the documentation of `spawn <#parallel-amp-spawn-spawn-statement>`_ for details.
12401214

12411215

12421216
Dynamic arguments for bindSym

0 commit comments

Comments
 (0)