blob: 2947aad92fb554d378c5e192bf82c88454697f79 [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001SYNOPSIS
2 void destruct(object ob)
3
Zesstra715ec202025-07-09 22:18:31 +02004DESCRIPTION
5 Completely destroy and remove object ob (if not already done so).
6 After the call to destruct(), no global variables will exist any
7 longer, only local ones, and arguments.
MG Mud User88f12472016-06-24 23:31:02 +02008
Zesstra715ec202025-07-09 22:18:31 +02009 If an object self-destructs, it will not immediately terminate
10 execution. If the efun this_object() will be called by the
11 destructed object, the result will be 0. Furthermore, all
12 calls to other objects and to simul-efuns will be ignored, instead
13 the driver will return 0 als 'call' result.
MG Mud User88f12472016-06-24 23:31:02 +020014
Zesstra715ec202025-07-09 22:18:31 +020015 To keep things consistent, most mudlibs frown upon the
16 destruct()ion of other objects, and instead demand call_others
17 to a specific lfun in the object to destruct (traditionally
18 named "remove"). This will then ensure correct update of e.g.
19 weights, volumes etc. Additionally or instead, the master apply
20 prepare_destruct() can be used for this 'cleanup' functionality.
MG Mud User88f12472016-06-24 23:31:02 +020021
Zesstra715ec202025-07-09 22:18:31 +020022 The interpreter does not really destruct the object
23 immediately, but marks it as deleted, removes it from the list
24 of all objects, and puts it onto a list of to-be-destructed
25 objects. The actual freeing occurs only when all references to
26 a destructed object have gone. Thus it is possible, that an
27 object occupies memory long after it has been destructed,
28 although the object is not visible anywhere anymore from
29 outside.
MG Mud User88f12472016-06-24 23:31:02 +020030
Zesstra715ec202025-07-09 22:18:31 +020031EXAMPLES
MG Mud User88f12472016-06-24 23:31:02 +020032 ob->remove();
Zesstra715ec202025-07-09 22:18:31 +020033 if(ob) /* still there, probably ob does not provide remove() */
34 destruct(ob);
MG Mud User88f12472016-06-24 23:31:02 +020035
Zesstra715ec202025-07-09 22:18:31 +020036 This is a way of destructing an object but giving it a chance
37 to do it by itself.
MG Mud User88f12472016-06-24 23:31:02 +020038
Zesstra715ec202025-07-09 22:18:31 +020039HISTORY
40 Changed in 3.2.7 to accept destructed objects as argument, too.
MG Mud User88f12472016-06-24 23:31:02 +020041
Zesstra715ec202025-07-09 22:18:31 +020042SEE ALSO
43 clone_object(E), remove(A), prepare_destruct(M)