6 The Inspector

6.2 Operating upon objects

Consider the following example, where a closure is defined:

CL-USER 12 > (let ((ernie (make-instance 'eagle)))
               (defun is-ernie-golden ()
                 (slot-value ernie 'golden)))
IS-ERNIE-GOLDEN

CL-USER 13 >

This has defined the function IS-ERNIE-GOLDEN, which is a closure over the variable ernie, where the value of ernie is an eagle.

1. Select Inspect from the Listener's Value menu.

The inspector examines the symbol IS-ERNIE-GOLDEN.

If you click once on an item in the contents pane, the Item menu becomes active. You can choose actions from the menu to perform upon the item.

2. Click on the FUNCTION item to select the closure.

Selecting the Item menu's Inspect option lets you inspect the selected item.

3. Select the Inspect option from the Item menu.

The closure is inspected, showing the variable ernie.

Note: You can also double-click upon an item in the contents pane to inspect it.

4. Double-click on ERNIE.

ernie is inspected.

Before continuing with this example, note that the following examination operations are also available from the Item menu.

The Class option invokes the class browser so that you can examine the class of the selected item. See Chapter 5, "The Class Browser", for more details.

The Find Definition option searches for the definition of the selected item in all of the code so far evaluated from files. If it is found, the file is made available for perusal in the editor. The cursor is placed at the start of the definition.

Note: You can find only the definitions of your own symbols (that is, those for which you have written source code), not those provided by FreeLisp.

The Trace submenu provides four tracer options: Trace Access, Trace Read, Trace Write, and Untrace Access. See Chapter 9, "The Tracer" for details of these facilities.

The Set option on the Item menu allows you to change the value of an item in the inspector's contents pane. Selecting Set produces a dialog into which you can type a new value for the item.

Continuing the current example, recall that the inspector is examining the eagle instance which is the value of ernie. Follow the instructions below:

1. Select the slot GOLDEN in the contents pane.

2. Select Set from the Item menu.

A dialog appears into which you can type a new value for the slot GOLDEN.

Figure 6.4 Entering a new slot value.

3. Type 'yes in the dialog and click on OK.

The contents pane reflects the new value of GOLDEN.

Figure 6.5 Inspection of the eagle instance with the golden slot assigned.

4. Continue the session as follows:

CL-USER 13 > (is-ernie-golden)
YES

CL-USER 14 >

The Item menu's Copy and Paste options allow you to copy the contents of slots and paste values into them. This sort of activity is particularly useful when debugging: you might inspect an object and see that it contains incorrect values. Using these options, you can copy values from the object's slots and paste them into other slots or tools, before continuing a program's execution.

To see how the options work, consider the following example:

CL-USER 13 > (setq fluffy (make-instance 'animal))
#<ANIMAL 005C043C>

CL-USER 14 > 

Now follow the instructions below:

1. Using the Edit menus in the Listener and inspector, Copy fluffy and Paste it into the inspector.

There is no value in the slot sex.

Figure 6.6 Inspection of the animal fluffy.

2. Continue the Common Lisp session as follows:

CL-USER 14 > 'male
MALE

CL-USER 15 >

3. Select the slot sex in the inspector.

Notice that the inspector's Item menu becomes active.

4. Copy the 'male symbol using the Listener's Edit menu.

5. Paste the 'male symbol into the slot sex using the inspector's Item menu

The inspector sets fluffy's sex to male:

Figure 6.7 Inspection of the animal fluffy with sex assigned.

You can also use Copy in the Item menu to copy this value to other objects in the inspector, or even to other tools. Suppose that you had another animal whose slot sex contained no value. You could set it to male as follows:

6. Continue the Common Lisp session:

CL-USER 15 > (setq snuffy (make-instance 'animal))
#<ANIMAL 005CBCCC>

CL-USER 16 >

7. Copy snuffy and Paste it into the inspector using the Edit menus as before

There is no value in the slot sex.

Figure 6.8 Inspection of the animal snuffy.

8. Using the inspector's History menu, swap the currently inspected object back to fluffy (the other animal object, not currently marked by a tick).

9. Select the instance's slot sex again.

10. Copy the value in the slot sex using the Item menu.

11. Using the History menu again, swap back to snuffy.

12. Select the instance's slot sex again.

13. Paste the 'male value into sex using the Item menu.

The inspector makes snuffy male:

Figure 6.9 Inspection of the animal snuffy with sex assigned.


FreeLisp User's Guide - 5 FEB 1996

Generated with Harlequin WebMaker