Next Previous Up Top Contents Index

2.3 Problems at run time

2.3.3 Browsing definitions

In this section, we browse the definition of reversi-square-write-data to see whether it converts the board squares into integers.

To browse the definition, we have the option of locating it on the project window Definitions page or (more efficiently) moving it directly in the browser.

1. Delete the text in the browser's Object field and type reversi-square-write-data in its place.
2. Press Return.

The browser switches to the definition of the reversi-square-write-data method. When we browse a definition as opposed to an instance, the browser usually shows a larger set of property pages that supply a lot of information about the definition and the relationships between it and other definitions in a project. The default property page here is the Source page, which shows the source code for the method.

Here is the code:

define method reversi-square-write-data
    (square :: <piece>, stream :: <file-stream>)
  => ()
   write-element(stream, number-for-piece(square));
end method reversi-square-write-data

So number-for-piece is most likely returning the integer value that was passed to write-element (and that we can see on the stack as the elt local variable). The square value has type <piece>--this, then, is the element type of the sequence used to represent the state of the board.

3. Browse the definition of number-for-piece.
You can do this either by typing the name into the Object field, or by clicking on the name on the Source page and selecting Browse from the right-click popup menu.

The definition of number-for-piece completes the story. It is here that the board square representations are converted into integers. This is where the integer that caused the exception came from.


Getting Started with Functional Developer - 31 MAR 2000

Next Previous Up Top Contents Index