Larry Wall <[EMAIL PROTECTED]> writes: > Me writes: > : > But suppose you want all .foo to refer to self and not > : > to the current topic. > : > : What about > : > : given (self) { .... } > > That wouldn't have the same effect as what we're talking about--it'd be > overruled by any C<given> within. We're talking about how to make .foo > mean self.foo regardless of the current topic.
Are we? I was looking for a way to unambgiously access the current object in such a way that topicalizers would still work, eg: use invocant 'it'; method foo($bar) { given .wibble($bar) { when .method { it.do_it(.attrib) } } } (I'm assuming here that, in a method, $bar is *not* the same as @_[0], which one would declare using C<method foo($bar:) {...}>). In the above chunk of code it'd be really nice if .method and .attrib were called on the results of .wibble($bar) (which was called on the current object), whilst 'it' unambiguously refers to the current object. The C<use invocant 'foo'> syntax is just a suggestion (and a way of dodging arguments about whether to call the object self/this/that/it/whatever because the programmer can cleave to his own taste. > : And "use me;" instead of "use invocant;"? > > And here "me" is referring to something that doesn't even necessarily > exist at the time of the declaration. Who is "me" at this point? Can I propose an 'abuse' builtin? Then one could say: C<use me; abuse me;>, which has to be good for poetry if nothing else. > In any event, I'm inclined to think that this whole "selfish" notion > of the object is a bit of a misnomer. We are a programmer. We are > not an object. We use "my" on lexical declarations because it's my > piece of code. Some of that code just happens to deal with objects, > but objects are "them" more than they're "us". C++ probably has the > more accurate idea here with "this", but maybe we've finally found a > good place for the occasionally proposed "it": > > it.foo(1); > > or even better: > > close it; > > On the other hand, "it" doesn't interpolate too well. And $_ is > still pronounced "it"... Personally, I like the 'self' notation; it encourages the programmer to think the 'right way around'. 'it' encourages one to think of objects doing things to objects, 'self' encourages to think of objects taking responsibility for their own data and asking other objects to do things for it. Hrm... I think I might need to think about that some more. > > But think of the commercial possibilities if your program starts out: > > just use it; > > Though I do wonder what > > use it or lose it; > > would mean... You are a *bad* man Mister Wall. -- Piers "It is a truth universally acknowledged that a language in possession of a rich syntax must be in need of a rewrite." -- Jane Austen?