in reply to Re: Re: Re: Mmmm ... cargo cult progamming is nummy!
in thread Adding autoloaded methods to symbol table with using strict refs
{...} there is prior art on this from Smalltalk. I'd be surprised if you haven't run across it. {...}So, to test your theory, I took the latest Squeak Smalltalk image (arguably derived directly from the original Xerox Park Smalltalk80 Image), and ran a few tests:
So there are 1280 classes in the current image. Now how many of them understand "new" as an instance method:Metaclass allInstances size -> 1280
There. The only two classes that have instances that understand #new are the things that act as factories: Behavior and Metaclass. And the code for Metaclass instances basically just says "don't do that" and throws an error. {grin} And the code is in Behavior so that all object classes also know how to #new themselves.Metaclass allInstances select: [:m | m soleInstance includesSelector: +#new] -> #(Behavior class Metaclass class)
So I go by my original hypothesis. In classic OO programming, best illustrated by Smalltalk80, the word "new" contains the strict connotation of "make a new instance of", and is applied only to class objects, not to instance objects.
By contrast, the Object implements both #clone (as a primitive) and #copy (to allow overriding for shallow copy vs deep copy), so every object knows how to clone itself.
-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: •Re: Re: Re: Re: Mmmm ... cargo cult progamming is nummy!
by dws (Chancellor) on May 19, 2003 at 17:51 UTC |