Toby Everett and I have come up with a Perl module that gives Perl a Self-like object model. If you're interested in using prototype-based programming but can't get Self to work, you might consider this.
Just to make a side note, one of the things we have demonstrated through this is that it is possible to add prototype-based semantics to class-based object-oriented languages that support run-time inspection and creation of classes. The metaphors of Self: prototype-based, mirrors and reflection, and slots, both data, method, and parent, all translated very well and proved very effective in what is still a very Perlish system. The end-result is that I can write Perl code using the approaches one uses in Self, and it is a very liberating and exciting feeling. One overloads the + operator by adding the method slot '+'. Classes and objects are both first-class citizens - they are virtually equivalent in the eyes of C::P (the only difference is that named classes persist even if there are no references to them, where as objects experience normal destructor behavior). Perl becomes a guise for Self:).
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.
--Toby Everett
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.
-- Jecel
On Thursday 02 August 2001 03:35 pm, you wrote:
One small step for Self, a giant leap for Perlkind! ;-)
Great job, guys.
Thanks!
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.
So we'll be able so see OO code like:
###~///~~3~#$~324#3"$#�$3$34�"# = abd*^!1/g//;
thanks to perl ;)
--- Jecel Assumpcao Jr jecel@merlintec.com 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.
-- Jecel
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
__________________________________________________ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/
self-interest@lists.selflanguage.org