[plt-scheme] "appending" to classes rather than extending

From: Jakub Piotr Cłapa (jpc-ml at zenburn.net)
Date: Thu Mar 6 19:13:06 EST 2008

Grant Rettke wrote:
> On Thu, Mar 6, 2008 at 8:13 AM, Matthias Felleisen <matthias at ccs.neu.edu> wrote:
> 
>> On Mar 6, 2008, at 9:06 AM, Chris Uzdavinis wrote:
>>> In Ruby, when you extend types, it affects existing objects of that
>>> type too.  Below, my_object is bound to an object created when X is an
>>> "empty" class, and then I add a bar method, and it's immediately
>>> available.
> 
>> I was afraid it would.
> 
>>From my perspective, most languages have, at one time or another, had
> some guiding vision or force behind them.
> 
> Eiffel has Bertrand Meyer saying "Everything is an object, and be
> static about it" and C++ has Bjorned Stroustrop saying "Keep it fast,
> keep it generic", Scheme "Programming languages should be designed not
> by piling feature ...".
> 
> Ruby has Yukihiro Matsumoto saying "It makes sense to me, if you don't
> like it, see you later!" hahaha
> 
> Consequently there are a lot of really "neat" things you can do in
> Ruby, but it is not always obvious to me why you might want to do
> those things (I'm excluding the *obvious* ones so give me a break on
> those). Mats knows, and if you don't "get it" oh well!

This particular feature is quite useful when you need to patch some 
class you don't hae source code for.

The main (not Ruby) users of such a feature are probably the Objective-C 
folks programming for NeXTSTEP/OS X (it's called categories and has it's 
limitations but hey, Objective-C was pioneering) . They seem to like it.

Oh. And there is this prototype based JavaScript which obviously also 
supports it. It works good as long as you use only one JS library at a 
time (namespace collisions are mostly ignored in the OO world; generic 
functions seem to fix this and are the most dynamic approach?). ;]

PS. Matthias, do you dislike generic functions?

-- 
regards,
Jakub Piotr Cłapa


Posted on the users mailing list.