#[unsafe(no_mangle)]pub unsafe extern "C" fn patch_seq_call(stack: Stack) -> StackExpand description
Call a quotation or closure
Pops a quotation or closure from the stack and executes it. For stateless quotations, calls the function with just the stack. For closures, calls the function with both the stack and captured environment. The function takes the current stack and returns a new stack.
Stack effect: ( ..a quot – ..b ) where the quotation has effect ( ..a – ..b )
§TCO Considerations
With Arc-based closure environments, this function is tail-position friendly: no cleanup is needed after the call returns (Arc ref-counting handles it).
However, full musttail TCO across quotations and closures is limited by
calling convention mismatches:
- Quotations use
tailccwith signature:fn(Stack) -> Stack - Closures use C convention with signature:
fn(Stack, *const Value, usize) -> Stack
LLVM’s musttail requires matching signatures, so the compiler can only
guarantee TCO within the same category (quotation-to-quotation or closure-to-closure).
Cross-category calls go through this function, which is still efficient but
doesn’t use musttail.
§Safety
- Stack must not be null
- Top of stack must be a Quotation or Closure value
- Function pointer must be valid
- Quotation signature: Stack -> Stack
- Closure signature: Stack, *const Value -> Stack