patch_seq_until_loop

Function patch_seq_until_loop 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn patch_seq_until_loop(stack: Stack) -> Stack
Expand description

Loop until a condition is true

Pops a condition quotation and a body quotation from the stack. Repeatedly executes: body quotation, then condition quotation, check result (Int: 0=false, non-zero=true), if false then continue loop, if true then exit.

This is the inverse of while: executes body at least once, then checks condition.

Stack effect: ( ..a body-quot cond-quot โ€“ ..a ) where body-quot has effect ( ..a โ€“ ..a ) and cond-quot has effect ( ..a โ€“ ..a Int )

ยงSafety

  • Stack must have at least 2 values
  • Top must be Quotation (condition)
  • Second must be Quotation (body)
  • Condition quotation must push exactly one Int
  • Body quotation must preserve stack shape