blob: e8f3f8f59b5f6b1c9dd9f74a3e6054286ad73814 [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001CONCEPT
2 lfuns
3
4DESCRIPTION
5 A lfun is a LPC function within an object which is public and can
6 be called by other objects. In OO terms, lfuns are "methods"
7 which you can send "messages" to.
8
9 Calling lfuns is done by using the efun call_other(), which
10 takes as arguments the object in which the lfun is to be called,
11 the name of the lfun to be called in the object, and additional
12 and optional arguments.
13
14 An example looks like this:
15
Zesstra98e90af2021-05-07 19:18:04 +020016 call_other(drink, "QueryShort");
MG Mud User88f12472016-06-24 23:31:02 +020017
18 This call may also be written as
19
Zesstra98e90af2021-05-07 19:18:04 +020020 drink->QueryShort();
MG Mud User88f12472016-06-24 23:31:02 +020021
22 This means call_other(object, "function", args...) can also be
23 written as object->function(args...). The second form is
24 preferred as it is easier to read.
25
Zesstra98e90af2021-05-07 19:18:04 +020026 call_other() will return 0, if the function does not exist
27 or is not accessible. As an alternative there is call_strict()
28 which will result in an error in such a case. The call is
29 similar:
30
31 call_strict(drink, "QueryShort")
32
33 And can be written as
34
35 drink.QueryShort();
36
MG Mud User88f12472016-06-24 23:31:02 +020037 Some lfuns have a special meaning for the LPC driver, because
38 they are applied by the interpreter instead from an LPC object.
39 To distinguish those, they are called ``applied lfuns''.
40
41SEE ALSO
42 efuns(LPC), efun(E), applied(A), master(M), call_other(E)