On Sat, Jul 06, 2002 at 03:32:11AM +0900, Tom Sawyer wrote:
> On Fri, 2002-07-05 at 05:31, Massimiliano Mirra wrote:
> > C'mon, for an object to be coupled to the one where it was created is
> > still a specific case, not the general one.  I don't think that in
> > `puts "hello, world"' you want the string to be coupled to the object.
> > Instead I think you'll want the coupling to be as clear as possible to
> > who reads the code, and both `x = X.new(self)' and `x.parent = self'
> > do this pretty good, don't they?
> 
> well, i just passed self, again. so imust ask you, how general is
> general? so far, just about every sizable script i write i end up
> passing self somewhere.

And I guess that even `somewhere' is very distant from `almost
anywhere', isn't it?

> "hello, world" is not a good example as it is an utterly useless
> program.

Every time you create a string, you are creating an object.  Do you
want all those strings (and numbers and everything else) implicitly
coupled with the context they are created in?  In other words, do you
want not to see, when reading code, what is coupled to what?

> useful programs are much more complex, where
> self passing is much more likely and useful.

Just issued this:

bard@prism:~/src/rpkg$ find . -name '*.rb' | xargs grep 'new(.*self.*)'

No result. :-)

> sure passing self isn't that bad. but i don't think accessing the
> creation-parent object is that uncommon.

Take one of those scripts and count the objects (including every
number, string, range, array... remember, everything is an object) and
compare the number of those where you needed to pass self to those
where you needed not.  Well, *that*'s `general'. :-)

Massimiliano