A location is a chunk of code between the following enter and leave actions:
mbfl_location_enter { ... } mbfl_location_leave
inside a location we can register a “handler command” that is automatically executed whenever the
location is left by calling mbfl_location_leave()
. We can nest locations at will. We can run
all the handlers registered so far in a stack of locations.
Enter into a new location. Initialise the internal state.
Leave the current location. Run all the registered handlers in reverse order.
Register a new handler in the current location. It is an error if this function is called outside a location.
Run all the handlers unwinding all the locations. This is useful as atexit handler, Running scripts at exit–time.
Enable or disable running the location handlers through an atexit handler. The enable operation registers an atexit handler that cleans up the current stack of locations.
• locations example1: | Single location, syntactic scoping. | |
• locations example2: | Nested locations. | |
• locations example3: | Nested function calls. |