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.
reversi-square-write-data in its place.
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.
number-for-piece.
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.