MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 1 | SYNOPSIS |
Zesstra | d59c389 | 2019-11-28 20:53:39 +0100 | [diff] [blame] | 2 | mixed deep_copy(mixed arg) |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 3 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 4 | DESCRIPTION |
| 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 User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 10 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 11 | For other values this function is a no-op. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 12 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 13 | 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 User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 15 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 16 | 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 | |
| 20 | EXAMPLES |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 21 | mixed *a, *b; |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 22 | |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 23 | a = ({ 1, ({ 21, 22 }) }); |
| 24 | b = deep_copy(a); |
| 25 | a[0] = -1; a[1][0] = -21; |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 26 | --> a is now ({ -1, ({ -21, 22 }) }) |
| 27 | b is still ({ 1, ({ 21, 22 }) }) |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 28 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 29 | HISTORY |
| 30 | Introduced in LDMud 3.2.6. |
| 31 | LDMud 3.2.9 added the dynamic cost to the efun. |
| 32 | |
| 33 | SEE ALSO |
| 34 | copy(E) |