Expression types are listed in order of increasing precedence.
Variable declarations are expressions in Nickle; the value of a declaration is the value of the last variable with an initialization expression. For example,
If no initialization expressions are present, it is an error to use the value of the expression.
Because they are expressions, declarations can be used in contructs such as:
Functions may be declared anonymously and used immediately, e.g.
Any context available to the function at definition time will be available whenever it is executed. See Storage classes in the section on Variables.
a + b
a - b
a * b
a / b |
a // b |
a % b
a ** b
a << b |
a >> b |
a ^ b |
a & b |
a | b |
a && b |
a || b |
a == b |
a != b |
a < b |
a <= b |
a > b |
a >= b |
a = b
a += b |
a -= b |
a *= b |
a /= b |
a //= b |
a %= b |
a **= b |
a >>= b |
a <<= b |
a ^= b |
a &= b |
a |= b |
* a
& a
- a
~ a
! a
a !
++ a |
a ++ |
-- a |
a -- |
Integer constants with a leading zero are interpreted in octal, with a leading 0x in hex-decimal and with a leading 0b in binary. Here are some examples:
Rational constants are the combination of an integer part, a mantissa with an initial and repeating part, and an exponent. All of these pieces are optional, but at least one of the parts (other than the exponent) must be present. If no fractional part is given, the resulting type of the value is int rather than rational. Some examples:
String constants are surrounded in double quotes, e.g. "hello, world". Characters preceded by a backslash stand for themselves, including double-quote (\") and blackslash (\\). The following backslashed characters are special:
\n is newline
\r is carriage return
\b is backspace
\t is tab
\f is formfeed
The name of a variable is replaced by the value of that variable in expressions. If the name is of a pointer, preceding it with the * dereference operator yields the value of its target.
The construct
yields the element name of the struct or union struct. To retrieve elements from a struct or union pointer, as in C, useElements of an array are indexed with square braces. Elements of multidimensional arrays have indices in each dimension as in the second form. Pointers to arrays can be indexed by placing the * dereference operator between the name of the array and the first square brace:
This is, however, deprecated in favor of using references to arrays, which have no such problems.
The fork operator evaluates its argument in a child thread. See the section on Concurrency.
Evaluates each expression in turn, the resulting value is that of the right hand expression. For example,