Evaluation rules
Observe the order of two calls
Both operands of this addition are evaluated, from left to right.
func mark(value):
print(value)
return value
print(mark(2) + mark(3))
2
3
5
The first call prints 2, the second prints 3, and the outer print displays their sum.
Integer literals have no unsigned suffix or digit separators. Use 0x or 0X for hexadecimal and 0b or 0B for binary. The minimum i64 literal is written with a leading minus. Floating literals start with a digit, have a decimal point followed by digits or an exponent, and must be finite. Use math.inf and math.nan to obtain special values. Only false and null are falsey, so zero, empty text, and empty collections are truthy.
A binary expression evaluates its left operand before its right. Calls evaluate the target and then the arguments from left to right. Use parentheses for a comparison chain's intended grouping, or combine separate comparisons with and. a < b < c groups as (a < b) < c, which compares a boolean to c and raises a type error. Prefix not consumes an expression starting at precedence 4 and binds more tightly than and. Eager binary arithmetic does not convert numeric text automatically. + concatenates text only when both operands are text. ?? selects its right side only for null. A later access after ?. needs its own optional operator when its receiver may be null.
Bitwise results use u64 when either operand of AND/OR/XOR is unsigned. Shifts use the type of the left operand and truncate shifted-out bits. Unary plus leaves the numeric representation unchanged. Unary minus on an unsigned value produces a signed result when representable. Negating the minimum i64 value as an operation overflows. Range equality compares both endpoints. Numeric and text ordering have separate operand categories. Apart from primitive/value equality, objects compare by identity. Ordered comparisons involving NaN on numeric operands are false.
assert(0xff == 255 and 0b10 == 2)
assert(2 ** 3 ** 2 == 512 and -2 ** 2 == -4)
assert(not 3 > 4 and 2 < 3)
assert((false ?? 'fallback') == false)
empty = null
assert((empty?.settings?.theme ?? 'light') == 'light')