[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
generic constructor functions
- To: CommonLoops.PA@Xerox.COM
- Subject: generic constructor functions
- From: Rick.Busdiecker@h.cs.cmu.edu
- Date: 26 Jun 87 22:43 EDT
Is there any reason not to have class constructor functions be generic
functions? I'd like to be able to do something like:
(defclass device () (viewports ...) (:constructor make-device))
(defclass viewport () (device ...)
(:constructor make-viewport ((device device) ...)))
(defclass X-device (device) (display ...) (:constructor make-X-device))
(defclass X-viewport (viewport) ()
(:constructor make-viewport ((device X-device) ...)))
instead of something like:
(defclass device ()
((viewport-constructor 'make-generic-viewport)
viewports ...)
(:constructor make-device))
(defclass viewport () (device ...)
(:constructor make-generic-viewport))
(defmethod make-viewport ((device device) &rest args)
(apply (viewport-constructor device) args))
(defclass X-device (device)
((viewport-constructor 'make-X-viewport)
display ...)
(:constructor make-X-device))
(defclass X-viewport (viewport) ()
(:constructor make-X-viewport))
The only advantage that I can think of having constructors be standard
functions is speed and I think that the advantages of having them be
generic functions out-weigh that consideration.
Rick