Warning: This is the manual of the legacy Guile 2.2 series. You may want to read the manual of the current stable series instead.

Next: , Previous: , Up: Instruction Set   [Contents][Index]


9.3.7.8 Dynamic Environment Instructions

Guile’s virtual machine has low-level support for dynamic-wind, dynamic binding, and composable prompts and aborts.

Instruction: abort x24:_

Abort to a prompt handler. The tag is expected in slot 1, and the rest of the values in the frame are returned to the prompt handler. This corresponds to a tail application of abort-to-prompt.

If no prompt can be found in the dynamic environment with the given tag, an error is signalled. Otherwise all arguments are passed to the prompt’s handler, along with the captured continuation, if necessary.

If the prompt’s handler can be proven to not reference the captured continuation, no continuation is allocated. This decision happens dynamically, at run-time; the general case is that the continuation may be captured, and thus resumed. A reinstated continuation will have its arguments pushed on the stack from slot 1, as if from a multiple-value return, and control resumes in the caller. Thus to the calling function, a call to abort-to-prompt looks like any other function call.

Instruction: prompt s24:tag b1:escape-only? x7:_ f24:proc-slot x8:_ l24:handler-offset

Push a new prompt on the dynamic stack, with a tag from tag and a handler at handler-offset words from the current ip.

If an abort is made to this prompt, control will jump to the handler. The handler will expect a multiple-value return as if from a call with the procedure at proc-slot, with the reified partial continuation as the first argument, followed by the values returned to the handler. If control returns to the handler, the prompt is already popped off by the abort mechanism. (Guile’s prompt implements Felleisen’s –F– operator.)

If escape-only? is nonzero, the prompt will be marked as escape-only, which allows an abort to this prompt to avoid reifying the continuation.

See Prompts, for more information on prompts.

Instruction: wind s12:winder s12:unwinder

Push wind and unwind procedures onto the dynamic stack. Note that neither are actually called; the compiler should emit calls to wind and unwind for the normal dynamic-wind control flow. Also note that the compiler should have inserted checks that they wind and unwind procs are thunks, if it could not prove that to be the case. See Dynamic Wind.

Instruction: unwind x24:_

a normal exit from the dynamic extent of an expression. Pop the top entry off of the dynamic stack.

Instruction: push-fluid s12:fluid s12:value

Dynamically bind value to fluid by creating a with-fluids object and pushing that object on the dynamic stack. See Fluids and Dynamic States.

Instruction: pop-fluid x24:_

Leave the dynamic extent of a with-fluid* expression, restoring the fluid to its previous value. push-fluid should always be balanced with pop-fluid.

Instruction: fluid-ref s12:dst s12:src

Reference the fluid in src, and place the value in dst.

Instruction: fluid-set! s12:fluid s12:val

Set the value of the fluid in dst to the value in src.

Instruction: current-thread s24:dst

Write the value of the current thread to dst.

Instruction: push-dynamic-state s24:state

Save the current set of fluid bindings on the dynamic stack and instate the bindings from state instead. See Fluids and Dynamic States.

Instruction: pop-dynamic-state x24:_

Restore a saved set of fluid bindings from the dynamic stack. push-dynamic-state should always be balanced with pop-dynamic-state.


Next: , Previous: , Up: Instruction Set   [Contents][Index]