Robert Dober wrote:
> On 9/29/06, Dr Nic <drnicwilliams / gmail.com> wrote:
>>
>> --
>> Posted via http://www.ruby-forum.com/.
>>
>> I'll have a look at T's link but it is a truely interesting discussion.

You're quoting techniques need some practise! I don't think I said that 
:)

> It is for the first time that I hear that very honorable members of the
> community dislike this feature.
> For me it was the most intreaging of Ruby at all (at the beginning)
> I recall my old Python code
> 
> something.get_other().do_stuff().transform()
> 
> Terrible, it is only now that I realize that the concept of writing code
> like this might be flawed, there are OTOH strong indications that it is 
> not
> so flawed too. E.g. lots of programing conventions asking for methods to
> return objects.
> Now, to complicate things even more, very often that object is "self",
> personally I find the idea to return other objects, especially proxy 
> objects
> to self, very intriguing, the idea came to me when I looked at the BDD 
> video cast.

In Smalltalk all methods return self unless they return something else, 
thus inferring that something.get_other().do_stuff().transform() (using 
Smalltalk syntax :) is common.

In JQuery - the javascript library - everything is centered around a 
"jquery" object which holds 1+ dom objects in it. All methods on the 
jQuery object should return that same set of objects (via the jQuery 
object container) so that you can chain method calls.

The idea of returning a proxy object (in the Magic Dot example of 
.map.lengths) was very nifty. It works the normal way AND works in the 
magical way.

The more and more examples I see and concoct myself like this the more I 
am happy to give up the core assumptions of "object oriented 
programming" etc, and adopt "happy syntax programming". Syntax that 
reads nicely and makes sense as to what it will do and what it will 
return.

Now if I could just get the code I originally wrote to work on 
ActiveRecord associations I'd be such a happy camper. I'm in love with 
that syntax.

Nic

-- 
Posted via http://www.ruby-forum.com/.