home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume10 / comobj.lisp / part01 / README < prev    next >
Text File  |  1987-07-30  |  14KB  |  417 lines

  1.         Revised Instructions for Installing and Using 
  2.         CommonObjects on CommonLoops
  3.             (COOL)
  4.  
  5. I) INTRODUCTION
  6.  
  7. COOL is an implementation of HP's CommonObjects on
  8. the Portable CommonLoops (PCL) metaclass kernel.
  9. As such, it provides a portable implementation of
  10. CommonObjects. It should be of particular interest
  11. to people who want to program in the mixin style
  12. supported by PCL but are also interested in trying
  13. the encapsulation style of Smalltalk, which CommonObjects
  14. supports.
  15.  
  16. This version of COOL is guaranteed to work with Portable
  17. CommonLoops system date 2-24-87. A copy of this version
  18. of Portable CommonLoops is distributed along with COOL.
  19.  
  20. COOL comes as a set of files grouped into four groups:
  21.  
  22.   1) Documentation
  23.  
  24.      README-this file
  25.  
  26.      semantics.asci-Description of semantic differences
  27.        between the CommonObjects specification in the
  28.        document ATC-85-01, "Object Oriented Programming
  29.        for Common Lisp," by Alan Snyder.
  30.  
  31.   2) The System
  32.      co-defsys.l
  33.      pcl-patches.l
  34.      co-parse.l
  35.      co-dtype.l
  36.      co-meta.l
  37.      co-dmeth.l
  38.      co-sfun.l
  39.  
  40.   3) Test and Profiling files
  41.  
  42.      co-test.l-A generalized version of the PCL test macro.
  43.      co-regress.l-Some simple regression tests for COOL.
  44.      co-profmacs.l-Macros for simplifying profiling.
  45.      co-prof.l-Profiling tests.
  46.  
  47.   4) Portable CommonLoops (system date 2-24-87)
  48.      The file <xxx>-low.l corresponds to the machine-dependent
  49.      file for your system. For HP Lisp, this will be hp-low.l.
  50.  
  51.      walk.l
  52.      macros.l
  53.      low.l
  54.      <xxx>-low.l
  55.      braid.l
  56.      class-slots.l
  57.      defclass.l
  58.      class-prot.l
  59.      methods.l
  60.      dfun-templ.l
  61.      fixup.l
  62.      high.l
  63.      compat.l
  64.  
  65. If you are on a Un*x system, the COOL files will be in the
  66. directory co/ and the PCL files will be in the directory pcl/.
  67.  
  68. If you have never programmed using CommonObjects, it is
  69. suggested you request a paper copy of ATC-85-01, "Object
  70. Oriented Programming for Common Lisp," by Alan Snyder;
  71. which is a specification of the CommonObjects language.
  72. It can be obtained by sending electronic mail with your
  73. name and address to mingus@hplabs.hp.com. If you are anxious
  74. to get started and don't want to wait for the specification,
  75. look at some of the test examples in co-regress.l for
  76. an idea of how to use CommonObjects.
  77.  
  78. II) BRINGING UP PORTABLE COMMONLOOPS
  79. Directions are given in the file defsys.l
  80. Briefly, one edits the variables *pcl-pathname-defaults* (which
  81. gives the location of the PCL files on your system). After that 
  82. the PCL files can be compiled by invoking:
  83.  
  84.    (require "defsys")
  85.    (pcl::compile-pcl)
  86.  
  87. and loaded by invoking:
  88.  
  89.    (pcl::load-pcl)
  90.  
  91. III) BRINGING UP COOL
  92.  
  93. Cool uses the PCL defsystem. Directions are given in the file
  94. co-defsys.l . Briefly, in file co-defsys.l, one sets the variable
  95. *co-pathname-defaults* to correspond to the location of the files
  96. on your local system. After that, the COOL files may be compiled by invoking:
  97.  
  98.    (require "co-defsys")
  99.    (co:compile-co)
  100.  
  101. and loaded by invoking:
  102.  
  103.    (co:load-co)
  104.  
  105. In addition, the file pcl-patches.l contains a patch for
  106. the PCL function CLASS-OF. This function is specialized
  107. for each implementation of Common Lisp, but, in the
  108. released version, it does not check if the type specifier
  109. returned by TYPE-OF is list. You will need to modify
  110. the SETQ of *CLASS-OF* in your implementation xxx-low.l
  111. file so that the function PCL::ATOM-TYPE-OF is called
  112. on (TYPE-OF X) instead of simply TYPE-OF. To see how this was
  113. done for HP Lisp, look at the top of pcl-patches.l
  114. Remember to put the form:
  115.  
  116. (eval-when (load eval)
  117.   (recompile-class-of)
  118.  
  119. )
  120.  
  121. in your file after you have rebound *CLASS-OF*; otherwise,
  122. the new definition will not take effect.
  123.  
  124. III) COMPILATION
  125.  
  126. You will probably want to compile COOL before using it,
  127. unless your system doesn't have a compiler. There
  128. are only three files in the COOL system itself. If
  129. you have set up your pathnames for REQUIRE correctly,
  130. then the following script should compile COOL:
  131.  
  132.    (require "co-defsys")
  133.    (co:compile-co)
  134.  
  135. You may want to turn on optimizations before compiling.
  136. Before doing this, it is suggested that you try the
  137. regression tests without any optimizations, in case
  138. your optimizer does something which might cause the
  139. system to break (like not checking for NIL during
  140. a CAR or CDR operation). For profiling, however, it
  141. is best to put as much optimization on as you think
  142. can safely be done.
  143.  
  144. IV) LOADING
  145.  
  146. To load the system, do the following:
  147.  (require "co-defsys")
  148.  (co:load-co)
  149.  
  150. V) USE
  151.  
  152. There are two steps needed to use the CommonObjects
  153. object oriented language extensions within your
  154. Common Lisp. 
  155.  
  156. First, in the package where you plan to use
  157. CommonObjects, you need to get access to the CommonObjects
  158. functions and macros. Do that by using the USE-PACKAGE
  159. form:
  160.  
  161. (in-package <your package>)
  162. (use-package 'co)
  163.  
  164. You will now have access to CommonObjects. Note to
  165. users on HP Lisp: it is not possible to use both
  166. COOL and the system dependent CommonObjects implementation
  167. in the same package, since a symbol conflict occurs
  168. upon import of the CommonObjects symbols.
  169.  
  170. It is suggested that you avoid trying to use both
  171. PCL and COOL in the same package. It MAY work,
  172. however, it has not been tried and is therefore
  173. untested. As a matter of good software engineering,
  174. it also seems best to try to segment applications
  175. which use both objects in different packages.
  176.  
  177. Second, there are a number of Common Lisp functions which
  178. CommonObjects semantics modify. These are EQL, EQUAL, EQUALP,
  179. TYPE-OF, and TYPEP. For more information on exactly what
  180. these modifications are, see ATC-85-01. Because redefining
  181. the default Lisp functions could be potentially very 
  182. dangerous or cause serious performance degradation, a 
  183. special macro has been constructed which SHADOWING-IMPORTs
  184. the redefined functions into a package using CO, without
  185. redefining the Common Lisp functions throughout the entire
  186. system. To get access to these functions, the macro
  187. IMPORT-SPECIALIZED-FUNCTIONS needs to be invoked after the
  188. CO package is used:
  189.  
  190.     (import-specialized-functions)
  191.  
  192. The Common Lisp functions will now locally reflect the
  193. CommonObjects semantics, but the global definitions
  194. are still available by using full package qualification
  195. of the names.
  196.  
  197. Here is a short description of the available CommonObjects
  198. operations exported from CO. For a more detailed description,
  199. see ATC-85-01.
  200.  
  201. (define-type <type name> <options>)        
  202.  
  203. Define a CommonObjects type whose name is <type name>. There
  204. are a whole host of options, including instance variable
  205. (slot) definition and inheritence. Macro.
  206.  
  207. (define-method (<type name> <method name>) (<arguments>)  
  208.     <body>
  209. )
  210.  
  211. Define a CommonObjects method named <method name> on <type name>.
  212. <method name> will typically be a keyword but need not be. Macro.
  213.  
  214. (call-method (<parent type name> <parent method name>) <arguments>) 
  215. (call-method <method name> arguments)
  216.  
  217. (apply-method (<parent type name> <parent method name>) &rest <arguments>)
  218. (apply-method <method name> &rest arguments)
  219.  
  220. Used to invoke a parent method or a method on SELF. The difference 
  221. from sending to SELF directly is that the method to call is
  222. determined at compile time. The CALL-METHOD form is like FUNCALL,
  223. APPLY-METHOD like APPLY. These forms are only valid within the
  224. body of a DEFINE-METHOD. Macros.
  225.  
  226. (make-instance <type name> <initialization keyword list>)
  227.  
  228. Make an instance of CommonObjects type <type name> The
  229. <initialization keyword list> is used to initialize
  230. instance variables and for other initialization purposes.
  231. PCL method.
  232.  
  233. (=> <instance> <method name> <arguments>)
  234.  
  235. Invoke operation <method name> on <instance> with <arguments>.
  236. This invocation operator makes no checks for errors and
  237. operates at full PCL messaging speed. Note that all arguments
  238. will be evaluated. Macro.
  239.  
  240. (send? <instance> <method name> <arguments>)
  241.  
  242. Invoke operation <method name> on <instance> with <arguments>,
  243. checking to be sure <instance> is a valid CommonObjects
  244. instance and that it supports <method name> as an operation.
  245. Returns NIL if the operation cannot be invoked. This
  246. invocation operator is slow but safe. Note that all arguments
  247. will be evaluated. Macro.
  248.  
  249. (instancep <arg>)
  250.  
  251. Returns T if <arg> is a CommonObjects instance, NIL if
  252. not. Function.
  253.  
  254. (supports-operation-p <arg> <method name>)
  255.  
  256. Returns T if <arg> supports operation <method name>,
  257. NIL if not. Function.
  258.  
  259. (assignedp <instance variable name>)
  260.  
  261. Returns T if <instance variable name> has been assigned
  262. a value, NIL if not. Valid only within a DEFINE-METHOD
  263. body. Macro.
  264.  
  265. (undefine-type <type name>)
  266.  
  267. Undefine the CommonObjects type <type name>. Returns T
  268. if the type was undefined, NIL if not. Signals an error
  269. if the argument is not a symbol. Function.
  270.  
  271. (rename-type <old type name> <new type name>)
  272.  
  273. Rename <old type name> to <new type name>. Returns T
  274. if the type was renamed. Signals an error if old
  275. type is not defined, if new type already exists,
  276. or if the arguments are not symbols. Function.
  277.  
  278. (undefine-method <type name> <method name>)
  279.  
  280. Undefine the method <method name> on <type name>.
  281. Signals an error if <type name> is not a symbol or
  282. if there is no type named <type name>. Issues a
  283. warning message if <method name> is a universal
  284. method and the type has the default universal
  285. methods. Returns T if the operation was successful,
  286. NIL if not. Function.
  287.  
  288.  
  289. VI) REGRESSION TESTS
  290.  
  291. The file co-regress.l contains a series of regression
  292. tests which test out important features of COOL.
  293. Some of these regression tests cause errors to be
  294. signalled, but, in order to have the tests complete
  295. successfully, the errors must be ignored. Since there
  296. is no portable way defined in CLtL to modify error
  297. handling (short of redefining the CL function ERROR)
  298. most system implementors have added extensions to
  299. do the job.
  300.  
  301. If you don't know what the extensions are on your
  302. system, or don't want to be bothered about trying
  303. to find out, skip this paragraph and go on to
  304. the next, but first a warning: the tests requiring
  305. error handling will be skipped, but the result
  306. may be that some implementation dependent problem
  307. is missed. If you know what the extensions are,
  308. then edit the file co-test.l. Go to the top
  309. of the file and look for the special variable
  310. *WITHOUT-ERRORS*. This variable should contain
  311. a function which generates the test with an error
  312. catcher in place around the code. Add
  313. #+<implementation name> to the list, and a LAMBDA
  314. definition to return the proper test code with
  315. error catching. Note that the code should return T
  316. if an error occurs, and NIL if not, for the
  317. test macro to work correctly. When you are done,
  318. mail that portion of the file with your system
  319. dependent code to cool@hplabs.hp.com.
  320.  
  321. To run the regression tests, simply REQUIRE the
  322. file co-regress.l:
  323.  
  324.     (require "co-regress")
  325.  
  326. The test results will be printed to the standard
  327. output.
  328.  
  329. Note that the regression tests make no checks
  330. for compilation, since the compilation semantics
  331. of PCL (upon which COOL is based) are very weakly
  332. defined. File compilation should work, however.
  333.  
  334. VII) PROFILING
  335.  
  336. If you're really feeling ambitious, you may even
  337. want to run the profiling tests to see how well
  338. your COOL is performing. 
  339.  
  340. Again, there are some implementation dependencies 
  341. which should be addressed before running the profiling
  342. tests. Probably the most important is that the name
  343. of the implementation's garbage collector be known.
  344. If this is NOT done, then you run the risk of having
  345. a garbage collect occur in the middle of the profiling,
  346. which will destroy your measurements. If your system
  347. has a large enough virtual image, however, garbage
  348. collection may not be a problem.
  349.  
  350. Edit the file co-profmacs.l and look at the top below
  351. the header. The function cell of the symbol
  352. DO-GARBAGE-COLLECT should be set to the function
  353. for your implementation's garbage collector. Be
  354. sure to put a #+<implementation name> before any
  355. implementation dependent code you may add. The default
  356. for garbage collection is to simply warn the user
  357. that the measurements may be in error because
  358. the test can't garbage collect.
  359.  
  360. You may also want to add any implementation dependent
  361. code for getting clock values. The default is the
  362. Common Lisp function GET-INTERNAL-REAL-TIME, and
  363. the clock increment in milliseconds (in the
  364. special variable *CLOCK-INCREMENT-IN-MILLISECONDS*)
  365. is calculated using the Common Lisp special
  366. INTERNAL-TIME-UNITS-PER-SECOND. However, many
  367. implementations may have special ways of getting 
  368. clock values, and these should be added here.
  369.  
  370. Please send any implementation dependent changes
  371. to cool@hplabs.hp.com.
  372.  
  373. The results of the profiling tests are put into
  374. a file whose name (as a string) is bound to the
  375. special variable TEST::*OUTPUT-FILE-NAME*. The
  376. default string is "runprof.out", as can be
  377. seen by checking the special variable definition
  378. for *OUTPUT-FILE-NAME* at the top of co-prof.l.
  379. If you want the results in another file, please
  380. SETF this variable to the file name before
  381. starting the profiling:
  382.  
  383.     (in-package 'test)
  384.     (setf *output-file-name* <your file name>)
  385.  
  386. To run the profiling tests, just:
  387.  
  388.     (require "co-prof")
  389.  
  390. and, providing you've set up your REQUIRE pathnames
  391. correctly, you should find it.
  392.  
  393. Note that profiling may take quite a while, and
  394. it is a good idea to have as little else going on
  395. on your machine as possible during the tests.
  396.  
  397. If you feel you want to distribute the profile
  398. information, you may want to send it to 
  399. cool@hplabs.hp.com with a brief description of
  400. your system. It might help identify particular
  401. implementation dependencies which are causing
  402. performance problems.
  403.  
  404. VIII) CONCLUSION
  405.  
  406. If you have problems with COOL or find any bugs,
  407. please report them to cool@hplabs.hp.com. It
  408. is most helpful if the bug can be as isolated
  409. as possible (e.g. "It broke when I defined
  410. type xxx" is less easy to trace down than
  411. a backtrace listing where it broke). It may
  412. be difficult to track all implementations of
  413. Common Lisp, but an effort will be made to
  414. keep COOL running as long as people are
  415. interested.
  416.  
  417.