[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: accessor functions
Date: Thu, 24 Jul 86 12:25:12 PDT
From: Alan Snyder <snyder%hplsny@hplabs.HP.COM>
Also, do you use the CLASS- prefix for ALL operations defined
on a CLASS, or just the instance variable accessor functions?
I notice in the SHIP example in the December 85 New Flavors paper that
the function SHIP-MASS is defined to read the MASS instance variable,
but the function SPEED (rather than SHIP-SPEED) is defined to
compute the speed. Is MASS less generic than SPEED?
In this particular example, yes, MASS is less generic than SPEED. All
this shows is that it's a poorly-crafted example, and all that shows is
that it is difficult to concoct a ten-line example of how to use object-
oriented programming, because object-oriented programming is useful
primarily for organizing very large programs, and in very small programs
just seems to get in the way. It's difficult to give a good explanation
of how one organizes a taxonomy of classes and protocols when the world
contains nothing but one class of ships and one class of (massless)
comets. The example was really only intended to convey syntax to those
who already knew how to use object-oriented programming.
If you want to know why the default for :CONC-NAME in DEFFLAVOR is what
it is, the easy answer is that I assumed the designers of Common Lisp
DEFSTRUCT knew what they were doing so I did the same thing. A less
flip answer is that if there is to be a default at all, rather than
requiring the user to specify it explicitly, the safest default is the
name of the flavor. This is based on the principle that defaults should
serve the needs of less sophisticated users, who are least well equipped
to choose a value for the option. In this case I am thinking of the
user with a small program, with only a single implementation of each
protocol, and probably lacking a clear articulation of the distinction
between protocols and implementations of protocols.