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

Re: make() and initialize()?




Nolan Darilek wrote in message <200005211856.OAA21139@life.ai.mit.edu>...
>I've finally encountered a situation in which I'd like to override the
>default/generated constructors. I've seen code which overrides make,
>and code which overrides initialize on the new class. What is the
>difference between make() and initialize()?

'make' allocates a new instance.  You can completely override 'make',
for example, if you are maintaining a cache of objects and want to
return an existing object.  'make(<vector>)' in Fun-O Dylan does this
to return a canonical empty vector, e.g.

'initialize' initializes its slots.  You can't completely override
'initialize'
methods.  They should always have a call to 'next-method()' in there
somewhere, most often at the very beginning.