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:
Metaclass allInstances size -> 1280
So there are 1280 classes in the current image. Now how many of them understand "new" as an instance method:
Metaclass allInstances select: [:m | m soleInstance includesSelector: +#new] -> #(Behavior class Metaclass class)
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.

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
    So, to test your theory, I took the latest Squeak Smalltalk image (arguably derived directly from the original Xerox Park Smalltalk80 Image)

    merlyn and I have been doing some digging, which I'll record here in case this discussion resurfaces in the future.

    I overgeneralized when claiming prior art in Smalltalk, and should have claimed prior art in VisualWorks, which was ParcPlace's "fork" of st80 (ParcPlace split off from Xerox Parc to commercialize Smalltalk). I have an image from the VisualWorks 2.5 era which contains an instance-side new, albeit in a dubious chunk of code that was later excised from the image. merlyn has verified that there are no instance-side new methods on VisualWorks 7.

    So, the bottom line is that isn't good, solid prior art in Smalltalk for an instance new method. At best there was a failed experiment.