uif

uif (condition trueCallable falseCallable -- branchResult)

Inputs

Outputs

uif selects between two already-selected Block branches by one known Cond value.

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

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