result is taken as a .
In m4nfo, a 'block' constitutes the function body of a performance function. As such, it is technically a parameter of that function, most of the time the only and last one. But unlike a normal parameter, it does not assign numerical values, text strings or functions, but represents a sequence of code, conditionally executed depending on how the flow of control is altered by the return value of its embedding performance function. In this way, it consists of a number of references (chaining to other functions) or callback results, each selected by the if() function, and a single else branch, very much like a 'C' switch/case construct.
def(10) typecount(TOWN, ref(9) if(0) ref(8) if(1) ref(7) if(2 .. 3) DISALLOW else )
In this example, there is one normal parameter (TOWN), followed by a block, highlighted in yellow, as the performance function's second parameter. There are three references and one callback result (DISALLOW) inside the block.
Each line of code in a block must consist of a reference or a callback result followed either by the if() function or the else label at the end of the block.
In case of an empty block (i.e. no if() function) the function´s result is taken as a callback result.
Parameters for the if() function may be a mixed list of single function return values, ranges of values, or unspecified ranges tagged by the numerical '<' or '>' symbol, see examples below.
Evaluation | Description |
if(1) | test for single return value |
if(1 .. 5) | test for range of return values |
if(1,3, 5) | test for single return values |
if(0 .. 2, 7 .. 9) | test for ranges of return values |
if(<20) | test for range 0 .. 19 [*] |
if(> 100) | test for range 101 .. <maxval>[*] |
if(0 .. 2,>100) | test for ranges 0 .. 2 and 101 .. <maxval> |
test for single return values 1, 3, 5, range 7 .. 9 and range 201 .. <maxval> |