blob: 0731151cb699706a1e3afef894923b8d17a84d4e [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001Procedural elements:
2====================
3
4definition of terms:
5 <block> : zero or more values to be evaluated.
6 <test> : one value to be evaluated as branch or loop condition.
7 <result> : one value to be evaluated at the end of the execution of
8 the form; the value is returned.
9 <lvalue> : local variable/parameter, global variable, or an indexed
10 lvalue.
11 <expression>: one value to be evaluated.
12 <integer> : an integer constant
13 <string> : a string constant, or 0.
14used EBNF operators:
15{ } iteration
16[ ] option
17| alternative
18
19forms:
20 ({#', <body> <result>})
21 ({#'? { <test> <result> } [ <result> ] })
22 ({#'?! { <test> <result> } [ <result> ] })
23 ({#'&& { test } })
24 ({#'|| { test } })
25 ({#'while <test> <result> <body>...}) loop while test evaluates non-zero.
26 ({#'do <body> <test> <result>}) loop till test evaluates zero.
27 ({#'foreach <var> <expr> <body>...}) loop over all values of <expr>.
28 ({#'foreach ({ <var>...<var> }) <expr> <body>...})
29 ({#'= { <lvalue> <value> } }) assignment
30 other assignment operators work too.
31 case_label: <integer> | <string> | #'default
32 generalized_case_label: case_label | <integer> #'.. <integer>
33 case_label_list: case_label | ({ { generalized_case_label } })
34 case_delimiter: #', | #'break
35 ({#'switch <expression> { case_label_list <result> case_delimiter } })
36 Evaluate expression, then evaluate the result form labeled with
37 the value equal to the value evaluated from expression.
38 If no matching label exists, the value of #'switch is 0.
Zesstra3085c662025-08-02 18:31:10 +020039 ({#'catch, <body> [, 'nolog ] [, 'publish ] [, 'reserve, <expr> ]
40 [, 'limit, <expr> ] })
MG Mud User88f12472016-06-24 23:31:02 +020041 Evaluates the <body> and catches any runtime error. If the symbol
42 'nolog is also given, a caught error is not logged. If the
43 symbol 'publish is also given, master::runtime_error() is
44 called for the caught error. If the symbol 'reserve with a
45 following expression is given, this value is used as the
46 computing reserve.
47
48
49lisp similars:
50 #', progn
51 #'? cond
52 #'&& and
53 #'|| or
54 #'while do /* but lisp has more syntactic candy here */
55 #'= setq
56
57A parameter / local variable 'foo' is referenced as 'foo , a global
58variable as ({#'foo}) . In lvalue positions (assignment), you need not
59enclose global variable closures in arrays.
60
61Call by reference parameters are given with ({#'&, <lvalue>})
62
63Some special efuns:
64#'[ indexing
65#'[< indexing from the end
66#'negate unary -
67
68Unbound lambda closures
69=======================
70
71These closures are not bound to any object. They are created with the efun
72unbound_lambda() . They cannot contain references to global variables, and
73all lfun closures are inserted as is, since there is no native object for
74this closure.
75You can bind and rebind unbound lambda closures to an object with efun
76bind_lambda() You need to bind it before it can be called. Ordinary objects
77can obly bind to themselves, binding to other objects causes a privilege
78violation().
79The point is that previous_object for calls done from inside the closure
80will reflect the object doing bind_lambda(), and all object / uid based
81security will also refer to this object.
82
83