[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Constructors



    The argument I buy for having constructors is that they provide
    a more abstract interface than make-instance. Using the Principle
    of Insignificant Degradation and Occam's Chainsaw, I don't think
    that make-instance and constructors burden the user with too many
    ways to do things, given that one is an abstraction mechanism.

The abstract interfaces are functions that the user can write, with very
few extra characters.  Occam's chainsaw cuts off extra mechanism when it
serves no real purpose.   The extra syntax in defclass, the functions to
make constructors, etc are all extra baggage   

One compares:

(defclass foo ()
   (a b)
   (:constructor make-foo))

with 

(defclass foo ()
   (a b))

(defun make-foo (initargs)
   (make-instance 'foo initargs))

And then if the user decides to have make-foo do some additonal work,
there is appropriate place to put the code.