|Version 6 (modified by mikel, 7 years ago) (diff)|
Writing the Lisp Code
In this section we'll write Lisp code that duplicates the features provided by the Objective C code in Apple's tutorial. In Apple's tutorial, the explanation of the Objective C code begins with the section Bridging the Model and View: The Controller.
The Lisp code in this section of the HOWTO is considerably simpler than the corresponding Objective C code, in part because we can ignore the conventions that XCode uses for laying out source files. We can just write all our definitions into a single Lisp source file, and load that file into Clozure CL when we are ready to build the application. The Lisp code is also a little more compact than the corresponding Objective-C.
First Things First
Place the following line at the top of your Lisp source file:
OpenMCL's Objective-C bridge code is defined in the "CCL" package. Usually, when building an application, you'll create a package for that application and import the definitions you need to use. In order to keep the discussion short in this simple example, we just place all our definitions in the "CCL" package.
Defining the Converter Class
We begin by defining the Converter class. Recall from Apple's tutorial that this is the Model class that implements the conversion between dollars and other currencies. Here is the Lisp definition that implements the class you created in InterfaceBuilder?:
(defclass converter (ns:ns-object) () (:metaclass ns:+ns-object))