Expand description
Evaluating a comprehension’s where predicate against a tuple.
A CompiledPredicate parses the predicate once
(parse_predicate) and tests each tuple against the tree. ||,
&&, !, the comparisons, and membership evaluate directly over
the tuple’s values. && and || evaluate their operands left to
right and stop at the first that decides the result, so filters
folded into one conjunction (R6) evaluate exactly what the chain
did; ! negates its operand’s truth. A
{name} the tuple does not bind resolves in the scope the tuple was
drawn in. Any other expression (arithmetic, a function call, a cast)
is interpolated against the tuple over that scope and evaluated as a
Polydat expression, charged to the scope’s ledger.
Values compare as scalars: integers and floats compare numerically
with each other, strings and booleans with their own kind, and a
value of one kind is never equal to a value of another, so
"s0" != 2 holds. Ordering values of different kinds is an error.
A string is quoted; a bare word is a name, and a predicate has no
names beside its elements. A predicate that does not parse is
evaluated whole as a Polydat expression. The value a predicate
yields is true when it is true or a non-zero number.
None propagates (none_semantics.md Rule 1, comprehension_forms.md
§10.9.1). An element the tuple binds to None, and a name that
neither the tuple nor the scope binds, reads None, and so does a
bare word. A comparison, a membership test, a negation, and an
expression that reads None are None; && and || stop at an
operand that is None, and are None. A predicate whose value is None
keeps no tuple.
Structs§
- Compiled
Predicate - A predicate parsed once, testing tuples.
Enums§
- Value
Kind - The kind every value of an element has, as its source declares it.
Functions§
- element_
kind - The kind of every value
nametakes inc: the kind its clause’s source declares, the same in every branch of a union, orNonewhen a source’s values are of unknown or mixed kind orcdoes not bindname.