blob: 39f8e88bd4eb26df66bee306cb5751a8c6f992b7 [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001SYNOPSIS
Zesstrab6ac9f62020-01-21 11:11:16 +01002 void replace_program()
3 void replace_program(string program)
MG Mud User88f12472016-06-24 23:31:02 +02004
Zesstra715ec202025-07-09 22:18:31 +02005DESCRIPTION
6 Substitutes a program with the inherited program <program>. If
7 the object inherits only one program, the argument may be omitted
8 and the efun will automatically select the one inherited program.
MG Mud User88f12472016-06-24 23:31:02 +02009
Zesstra715ec202025-07-09 22:18:31 +020010 This efun is useful if you consider the performance and memory
11 consumption of the driver. A program which doesn't need any additional
12 variables and functions (except during creation) can call
13 replace_program() to increase the function-cache hit-rate of the
14 driver which decreases with the number of programs in the system.
MG Mud User88f12472016-06-24 23:31:02 +020015
Zesstra715ec202025-07-09 22:18:31 +020016 Rooms are a good example for the application of this function, as many
17 rooms just consist of an inherit statement and the configure function.
18 Any object can call replace_program() but looses all extra variables
19 and functions which are not defined by the inherited program.
MG Mud User88f12472016-06-24 23:31:02 +020020
Zesstra715ec202025-07-09 22:18:31 +020021 When replace_program() takes effect, shadowing is stopped on
22 the object since 3.2@166.
MG Mud User88f12472016-06-24 23:31:02 +020023
Zesstra715ec202025-07-09 22:18:31 +020024 It is not possible to replace the program of an object after (lambda)
25 closures have been bound to it. It is of course possible to first
26 replace the program and then bind lambda closures to it.
MG Mud User88f12472016-06-24 23:31:02 +020027
Zesstra715ec202025-07-09 22:18:31 +020028 The program replacement does not take place with the call to the efun,
29 but is merely scheduled to be carried out at the end of the backend
30 cycle. This may cause closures to have references to then vanished
31 lfuns of the object. This poses no problem as long as these references
32 are never executed after they became invalid.
MG Mud User88f12472016-06-24 23:31:02 +020033
Zesstra715ec202025-07-09 22:18:31 +020034HISTORY
35 LDMud 3.2.9 allowed to omit the argument if only one inherit
36 exists.