Structural Informatics Group (SIG) logo
Home | Projects | Demos | Downloads | Publications | Local Info | About Us | New site
Go to the first, previous, next, last section, table of contents.

A Better Class Example

The example previously shown does work, but the class and instances created don't really do anything of interest. The following example sets up a tool class and creates some tool instances.

 ________________________________________________________________
|
|       > (setq my-tools (send class :new '(power moveable operation)))
|       #<Object: #277a6>
|
|       > (send my-tools :answer :isnew '(pow mov op) 
|                                        '((setq power pow)
|                                          (setq moveable mov)
|                                          (setq operation op)))
|       #<Object: #277a6>
|
|       > (setq drill (send my-tools :new 'AC t 'holes))
|       #<Object: #2ddbc>
|
|       > (setq hand-saw (send my-tools :new 'none t 'cuts))
|       #<Object: #2dc40>
|
|       > (setq table-saw (send my-tools :new 'AC nil 'cuts))
|       #<Object: #2db00>
|________________________________________________________________

So, a class of objects called MY-TOOLS was created. Note that the class object MY-TOOLS was created by sending the :NEW message to the built-in CLASS object. Within the MY-TOOL class, there are three instances called DRILL, HAND-SAW and TABLE-SAW. These were created by sending the :NEW message to the MY-TOOLS class object. Notice that the parameters followed the message selector.


Go to the first, previous, next, last section, table of contents.