blob: 1a4d7e1aac0c46aa0c7fdd15ecb9d2faffdbc096 [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001SYNOPSIS
Zesstrad59c3892019-11-28 20:53:39 +01002 mixed deep_copy(mixed arg)
MG Mud User88f12472016-06-24 23:31:02 +02003
Zesstra715ec202025-07-09 22:18:31 +02004DESCRIPTION
5 Create a deep copy of <arg> and return it. For arrays, mappings,
6 structs and lightweight objects this means that a new array, mapping,
7 struct resp. lightweight object is created with copies of the
8 original content. Embedded arrays, mappings, structs or lightweight
9 objects are truly copied, too.
MG Mud User88f12472016-06-24 23:31:02 +020010
Zesstra715ec202025-07-09 22:18:31 +020011 For other values this function is a no-op.
MG Mud User88f12472016-06-24 23:31:02 +020012
Zesstra715ec202025-07-09 22:18:31 +020013 If a lightweight objects was copied, the H_CREATE_LWOBJECT_COPY hook
14 will be called to finish initialization of the lightweight object.
MG Mud User88f12472016-06-24 23:31:02 +020015
Zesstra715ec202025-07-09 22:18:31 +020016 If DYNAMIC_COST is defined, every nested array, mapping, struct and
17 lightweight objects counts towards the evaluation cost in both size
18 and nesting depth.
19
20EXAMPLES
MG Mud User88f12472016-06-24 23:31:02 +020021 mixed *a, *b;
Zesstra715ec202025-07-09 22:18:31 +020022
MG Mud User88f12472016-06-24 23:31:02 +020023 a = ({ 1, ({ 21, 22 }) });
24 b = deep_copy(a);
25 a[0] = -1; a[1][0] = -21;
Zesstra715ec202025-07-09 22:18:31 +020026 --> a is now ({ -1, ({ -21, 22 }) })
27 b is still ({ 1, ({ 21, 22 }) })
MG Mud User88f12472016-06-24 23:31:02 +020028
Zesstra715ec202025-07-09 22:18:31 +020029HISTORY
30 Introduced in LDMud 3.2.6.
31 LDMud 3.2.9 added the dynamic cost to the efun.
32
33SEE ALSO
34 copy(E)