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

self species new



Smalltalk has a convenient notation for getting the actual class of an
instance.  This is often used in copy() methods so a single superclass
implementation will work for subclasses.  The superclass method uses
newOne := self species new.  (or self class new - species seems an anachronism)
to get a new table of the same class as is being copied.  As I write the
Table->copy() routines, I note that the only difference in 4 implementations
is the step that creates the new table.
  Does anyone have a suggestion on how to do this in C++?  I'm not advocating
making the create methods into category methods.
  All this may not make much difference, as I see several of the copy routines
becoming very much more specific later to increase efficiency.
--Hguh

try:
--Hugh