home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / lisp / 3183 < prev    next >
Encoding:
Internet Message Format  |  1993-01-06  |  1.6 KB

  1. Path: sparky!uunet!munnari.oz.au!manuel.anu.edu.au!arp!gustav
  2. From: gustav@arp.anu.edu.au (Zdzislaw Meglicki)
  3. Newsgroups: comp.lang.lisp
  4. Subject: declaring CM pvars as classes
  5. Date: 6 Jan 1993 09:25:59 GMT
  6. Organization: Centre for Information Science Research, ANU, Canberra, Australia
  7. Lines: 34
  8. Sender: gustav@arp (Zdzislaw Meglicki)
  9. Distribution: world
  10. Message-ID: <1ie8j7INNdmh@manuel.anu.edu.au>
  11. NNTP-Posting-Host: 150.203.20.14
  12. Keywords: *Lisp, CLOS
  13.  
  14. I am trying to overload simple arithmetic operators such as +, *, etc
  15. in order to make a certain set of procedures more universal. In particular
  16. I have definitions such as:
  17.  
  18. (defmacro overload (name op)
  19.   `(progn
  20.      (overload-number-number ,name ,op)
  21.      (overload-vector-vector ,name)
  22.      (overload-vector-number ,name)
  23.      (overload-number-vector ,name)))
  24.  
  25. where an example of the "overload-number-number" macro may be:
  26.  
  27. (defmacro overload-number-number (name op)
  28.   `(defmethod ,name ((a1 number) (a2 number) &rest other-args)
  29.      (reduce #',name other-args 
  30.              :initial-value (,op a1 a2))))
  31.  
  32. This works fine with "number"s and "vector"s since CLOS recognises these
  33. as classes. But I cannot do
  34.  
  35. (defmethod plus ((a1 pvar) (a2 pvar) &rest other-args)
  36.     ...)
  37.  
  38. since CM's "pvar" is not recognised by CLOS as a class. What might be the
  39. best remedy to this problem? What would be the easiest way to define a
  40. class "pvar"?
  41.  
  42.  
  43. -- 
  44.    Zdzislaw Gustav Meglicki, gustav@arp.anu.edu.au,
  45.    Automated Reasoning Program - CISR, and Plasma Theory Group - RSPhysS,
  46.    The Australian National University, G.P.O. Box 4, Canberra, A.C.T., 2601, 
  47.    Australia, fax: (Australia)-6-249-0747, tel: (Australia)-6-249-0158
  48.