next up previous contents
Next: TEACH files and Up: PREFACE TO THE Previous: The need for

Monitors

Another thing missing from Pop-11 (and many other languages) is the concept of a `monitor' or `demon': a program which waits until some condition becomes true, and then immediately takes control and carries out its instructions. Thus you cannot say in Pop-11 something like

   'if ever the value of X becomes 99 then print out a warning'.
It is possible, using advanced facilities in Pop-11, to extend the language to allow such things. In particular Pop-11's interface to the X window system allows such monitors, or demons, know as "event handlers" to be attached to graphical windows or control panels. It is possible to attach a Pop-11 "call-back" procedure to a screen object. The procedure is then run whenever the user performs an action involving that object with the mouse, e.g. pointing at the object and clicking a mouse button.

There are also a few special purpose monitors built into Pop-11. For instance there is a procedure which is run whenever an error occurs, and the user can define that to take appropriate action. Also there is a user-definable procedure called `interrupt' which is run whenever the user types an interrupt character at the terminal (usually CTRL-C). Another is the user-definable procedure pop_after_gc which runs whenever an automatic garbage collection has occurred.

Further, it is possible to attach a monitor to a variable in Pop-11 by declaring the variable as "active". This means that a procedure can be associated with it which is run whenever the value is accessed, and another procedure which is run whenever the value is updated. For more information see the online file HELP ACTIVE_VARIABLES

Another feature that makes it possible to monitor events is the fact that access to data-structures goes via procedures rather than via compiled offsets. This means that by re-defining the procedures for accessing particular data-structures one can insert "traps" that are activated whenever the contents are examined, or changed. The user-definable "methods" supported by the Objectclass package also provide monitor-like facilities.



next up previous contents
Next: TEACH files and Up: PREFACE TO THE Previous: The need for



Aaron Sloman
Fri Jan 2 03:17:44 GMT 1998