Skip to main content

broadcast

Function broadcast 

Source
fn broadcast(
    left: NativeNode,
    right: NativeNode,
    op: BinaryOp,
    return_bool: bool,
) -> NativeNode
Expand description

Wraps two compiled operands in the binary node that applies op to them.

The output is the vector side’s own binding, because a scalar carries no fields: a broadcast keeps the vector’s fields and the grid it is evaluated on, which is the statement’s grid on both sides. Two scalars are possible as a nested operand — a pair that constant_value refuses to fold, such as a comparison between two constants — and the node reports the left one’s grid, which is the statement’s too. The operands keep the order they were written in, because a non-commutative operator means what that order says.