blob: 8ee701bc7267626b92d22d2b0b785faf418d3a73 [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001SYNOPSIS
Zesstrad59c3892019-11-28 20:53:39 +01002 mixed copy(mixed arg)
MG Mud User88f12472016-06-24 23:31:02 +02003
Zesstra715ec202025-07-09 22:18:31 +02004DESCRIPTION
5 Create a shallow 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 copied by reference!
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.
15
16EXAMPLES
Zesstrad59c3892019-11-28 20:53:39 +010017 mixed *a, *b;
Zesstra715ec202025-07-09 22:18:31 +020018
Zesstrad59c3892019-11-28 20:53:39 +010019 a = ({ 1, ({ 21, 22 }) });
20 b = copy(a);
21 a[0] = -1; a[1][0] = -21;
Zesstra715ec202025-07-09 22:18:31 +020022 --> a is now ({ -1, ({ -21, 22 }) })
23 b is now ({ 1, ({ -21, 22 }) })
Zesstrad59c3892019-11-28 20:53:39 +010024
Zesstra715ec202025-07-09 22:18:31 +020025HISTORY
26 Introduced in LDMud 3.2.6.
MG Mud User88f12472016-06-24 23:31:02 +020027
Zesstra715ec202025-07-09 22:18:31 +020028SEE ALSO
Zesstrad59c3892019-11-28 20:53:39 +010029 deep_copy(E)