We will now make a change to the Reversi application. We are going to add a new feature that allows someone playing Reversi to change the shape of the pieces.
If you look at the Reversi application again now, you will see that some of the commands on the Options menu--Circles, Squares and Triangles--are unavailable. Our changes will enable these items.
Among the Reversi example files, there is a prepared Dylan source file with the changes we need for this new piece-shapes code. It is not yet a part of the project, so to incorporate it into our Reversi application, we must add it to the project.
). When you ask to terminate an application in this way, the environment asks you for confirmation, to prevent application state being lost by accident.
The positions of files in the sources list are important. The last file in the list should always be the file that contains the code that starts the application running. Unlike C or Java, Dylan does not require us to write a function of a predetermined name in order to start an application. We simply make the last piece of code in the last source file an expression that does something with all the Dylan definitions that the source files contain.
In the Reversi project, start-reversi.dylan contains the code that starts the application and so must be at the bottom of the source file list. We want the file we are going to add to appear between board.dylan and start-reversi.dylan.
board.dylan.
piece-shapes.dylan and click Open.
piece-shapes.dylan below board.dylan.
Now that piece-shapes.dylan is part of the sources that will be used to build the Reversi application, we can rebuild the executable.
This time, Functional Developer compiles only one file: piece-shapes.dylan. No changes had been made to the existing source files, so it did not need to recompile them. It simply linked the existing compiled files with the new one to make the new executable.
This incremental compilation feature can save a lot of time during development, when you want to rebuild your application after a small change in order to test its effects. Functional Developer automatically works out which files it needs to recompile and which it does not. The compiler also updates a project's database during incremental compilation.
When compilation of piece-shapes.dylan is complete, there are still some serious warnings. The link warning dialog appears to ask you to confirm that you want to link an executable for Reversi.
We can now run the new version of Reversi.
Thanks to our compiling the changes to the project, the Circles, Squares, and Triangles items are now available:
Figure 1.8 The Reversi application's Options menu after the code changes.
Figure 1.9 The Reversi application with square pieces.