#[unsafe(no_mangle)]pub unsafe extern "C" fn patch_seq_spawn(stack: Stack) -> StackExpand description
Spawn a quotation or closure as a new strand (green thread)
Pops a quotation or closure from the stack and spawns it as a new strand.
- For Quotations: The quotation executes concurrently with an empty initial stack
- For Closures: The closure executes with its captured environment
Returns the strand ID.
Stack effect: ( ..a quot – ..a strand_id ) Spawns a quotation or closure as a new strand (green thread).
The child strand receives a COPY of the parent’s stack (after popping the quotation). This enables CSP/Actor patterns where actors receive arguments via the stack.
Stack effect: ( …args quotation – …args strand-id )
- Parent: keeps original stack with quotation removed, plus strand-id
- Child: gets a clone of the stack (without quotation)
§Safety
- Stack must have at least 1 value
- Top must be Quotation or Closure
- Function must be safe to execute on any thread