
For example, if the "increment" function is defined as follows:
increment(&value, incr=1)
{
value += incr
}
The following function calls are all the same:
increment(a)
increment(a, _)
increment(a, 1)
Standard values for arguments that are transferred as a reference are helpful in making these parameters
optional. For example, if the "divmod" function was written to return the quotient and the rest as a parameter.
divmod(a, b, "ient=0, &remainder=0)
{
quotient = a / b
remainder = a % b
}
Based on the previous definition of the "divmod" function, the following function calls are all valid:
new p, q
divmod(10, 3, p, q)
divmod(10, 3, p, _)
divmod(10, 3, _, q)
divmod(10, 3, p)
divmod 10, 3, p, q
The next example adds the value of an array to another one. The values of the array are increased by one if
only one parameter is specified:
addvector(a[], const b[] = {1, 1, 1}, size = 3)
{
for (new i = 0; i < size; i++)
a[i] += b[i]
}
12.6 Differences to C
l
The pawn is missing the input mechanism of C and is an "integer-only" variant of C. There are no
structures or unions. Floating point support must be implemented with user-defined operators and the
help of native functions.
l
The syntax for floating point values is stricter than that in C. Values such as ".5" and "6." are acceptable
in C but must be written as "0.5" and "6.0" in the pawn. The decimal point is optional in C. If an
exponent is included, then you can write "2E8" in C, however the pawn will not accept the capital letter
"E". Use the lower case letter "e". It requires a comma: e.g. "2.0e8" (see "Numerical constants" on
page 165).
182
Rev. 01
Содержание myDatalogEASY IoTmini
Страница 2: ......
Страница 11: ...Chapter 2 Declaration of conformity Chapter 2 Declaration of conformity Rev 01 11 ...
Страница 12: ......
Страница 34: ......
Страница 66: ......
Страница 78: ......
Страница 82: ......
Страница 186: ......
Страница 194: ......
Страница 196: ......
Страница 202: ......
Страница 205: ...Chapter 19 Document history Chapter 19 Document history Rev Date Changes 01 28 08 2020 First version Rev 01 205 ...
Страница 206: ......
Страница 208: ......