MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 1 | SYNOPSIS |
Zesstra | b6ac9f6 | 2020-01-21 11:11:16 +0100 | [diff] [blame] | 2 | void replace_program() |
| 3 | void replace_program(string program) |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 4 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 5 | DESCRIPTION |
| 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 User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 9 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 10 | 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 User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 15 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 16 | 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 User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 20 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 21 | When replace_program() takes effect, shadowing is stopped on |
| 22 | the object since 3.2@166. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 23 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 24 | 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 User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 27 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 28 | 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 User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 33 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 34 | HISTORY |
| 35 | LDMud 3.2.9 allowed to omit the argument if only one inherit |
| 36 | exists. |