[self-interest] Class::Prototyped - Fast prototype-based programming in Perl

Ned Konz ned at bike-nomad.com
Thu Aug 2 22:17:58 UTC 2001

On Thursday 02 August 2001 03:35 pm, you wrote:
> One small step for Self, a giant leap for Perlkind! ;-)
> Great job, guys.


> On Thursday 02 August 2001 08:12, Toby Everett wrote:
> > I see no reason why this same thing couldn't be done in other dynamic
> > class-based object-oriented languages.  Basically, all one has to do
> > is write a reflection system that uses the Self semantics and
> > translates those into the native inspection system.
> I am not sure about this. Most languages that are "loose enough" for
> this kind of messing around are already prototype based (Lua, for
> example). How would you do this in Smalltalk? I have no idea whether
> Python or Ruby have the needed hooks.

The method we used was to make "uniclasses" for Self-like objects. This 
method is already used in a limited way in Squeak's eToy system to allow user 
scripting of Morphs. However, to do this as efficiently as we did it for Perl 
in a single-inheritance language there would have to be some dependency 
mechanism  that would allow slots to be copied down into children.

This wasn't needed in Perl because of its extremely casual and lightweight 
multiple-inheritance model. This made things much easier to deal with. Each 
parent (class or object) is just another entry in the @ISA array that 
provides the extended method lookup order.

Ruby also only provides a single-inheritance model. But it has a notification 
mechanism in place that allows detecting when methods are added, or when 
classes are subclassed, or when a module is mixed in. I suspect you could 
also hook method removal. These hooks could be used as part of the basis for 
a system that updates child slots as needed. Or you could use 
method_missing() (Ruby's equivalent of Smalltalk's doesNotUnderstand), but it 
would be slower.

Ned Konz
currently: Stanwood, WA
email:     ned at bike-nomad.com
homepage:  http://bike-nomad.com

More information about the Self-interest mailing list