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 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 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 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. |
| 15 | |
| 16 | EXAMPLES |
Zesstra | d59c389 | 2019-11-28 20:53:39 +0100 | [diff] [blame] | 17 | mixed *a, *b; |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 18 | |
Zesstra | d59c389 | 2019-11-28 20:53:39 +0100 | [diff] [blame] | 19 | a = ({ 1, ({ 21, 22 }) }); |
| 20 | b = copy(a); |
| 21 | a[0] = -1; a[1][0] = -21; |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 22 | --> a is now ({ -1, ({ -21, 22 }) }) |
| 23 | b is now ({ 1, ({ -21, 22 }) }) |
Zesstra | d59c389 | 2019-11-28 20:53:39 +0100 | [diff] [blame] | 24 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 25 | HISTORY |
| 26 | Introduced in LDMud 3.2.6. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 27 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 28 | SEE ALSO |
Zesstra | d59c389 | 2019-11-28 20:53:39 +0100 | [diff] [blame] | 29 | deep_copy(E) |