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

Next: , Previous: , Up: Traps   [Contents][Index]


6.25.4.5 Trap States

When multiple traps are present in a system, we begin to have a bookkeeping problem. How are they named? How does one disable, enable, or delete them?

Guile’s answer to this is to keep an implicit per-thread trap state. The trap state object is not exposed to the user; rather, API that works on trap states fetches the current trap state from the dynamic environment.

Traps are identified by integers. A trap can be enabled, disabled, or removed, and can have an associated user-visible name.

These procedures have their own module:

(use-modules (system vm trap-state))
Scheme Procedure: add-trap! trap name

Add a trap to the current trap state, associating the given name with it. Returns a fresh trap identifier (an integer).

Note that usually the more specific functions detailed in High-Level Traps are used in preference to this one.

Scheme Procedure: list-traps

List the current set of traps, both enabled and disabled. Returns a list of integers.

Scheme Procedure: trap-name idx

Returns the name associated with trap idx, or #f if there is no such trap.

Scheme Procedure: trap-enabled? idx

Returns #t if trap idx is present and enabled, or #f otherwise.

Scheme Procedure: enable-trap! idx

Enables trap idx.

Scheme Procedure: disable-trap! idx

Disables trap idx.

Scheme Procedure: delete-trap! idx

Removes trap idx, disabling it first, if necessary.