uif (inputs... condition trueCallable falseCallable -- outputs...)
Inputs
inputs...: Zero or more objects supplied to the selected branch.condition: Known Cond that selects the branch.trueCallable: Already-selected Block processed inline whenconditionis true.falseCallable: Already-selected Block processed inline whenconditionis false.
Outputs
outputs...: Objects produced by the selected inline branch.
uif selects between two already-selected Block branches by one known Cond object.
The selected branch is processed inline in the current scope. Locals created there remain available afterward.
Only the selected branch is processed. The unselected branch is ignored completely, may be invalid, and no branch-output merge occurs.
Behavior
- Any additional data inputs used by a branch must already be below
condition,trueCallable, andfalseCallableon the data stack. - Before the selected branch is processed,
condition,trueCallable, andfalseCallableare removed from the stack. The selected branch sees only the remaining underlying data stack. TRUEselectstrueCallable.FALSEselectsfalseCallable.
Example
{} 0 {} [
TRUE [
7 "chosenTrue" def
"-- true branch --" printCompilerMessage
] [
impossibleName
] uif
FALSE [
impossibleOtherName
] [
8 "chosenFalse" def
"-- false branch --" printCompilerMessage
] uif
"-- after uif --" printCompilerMessage
chosenTrue printStack _:;
chosenFalse printStack _:;
"-- no branch merge --" printCompilerMessage
TRUE [1] [FALSE] uif printStack _:;
0
] "main" exportFunction
Expected Output During Compilation
-- true branch --
-- false branch --
-- after uif --
7 Cref
8 Cref
-- no branch merge --
1
See also
callbuiltin(inputs... callable -- outputs...)Calls an already-selected Block, Code, callable Dict, or known Text through a call boundary. No selection happens inside the builtin.ifbuiltin(inputs... condition trueCallable falseCallable -- outputs...)Selects between two already-selected Block branches by Cond. Unknown conditions require both branches to be compiled and merged.loopbuiltin(inputs... callable -- outputs...)Repeatedly calls one already-selected Block through a call boundary. The run-time repetition invariant is(A -- A Cond): each body call preserves the carried stack’s shape — the number of objects and their schemas — not necessarily their values, and leaves a final Cond; known-condition iterations may add items or change schemas.ucallbuiltin(inputs... callable -- outputs...)Processes an already-selected Block or known Text inline in the current scope.