Luke Palmer skribis 2005-03-29 6:14 (-0700): > method iterate () { > for (@.objs) { > .process($_); # oops > } > }
There is an alarming similarity with for (@hashes) { .<process>($_) } Which doesn't quite use $self! .<>, .[], .{} are method calls, visually, and should act on the same thing as their unbracketed dot friends. Subscripting an object is bad style, so $_ for that really is the better option, I think. $_ is the topic, and I think that if we have two topics, Perl gets as convoluted as Japanese for someone who doesn't understand the language. With loop constructs, the idiomatic syntax for getting a non-$_ is "-> $foo", and a similar thing can be done with methods: "($foo:)". But please, let's have a single topic, and let that always be $_. If you want to access an outer $_, that's $OUTER::_, or its alias, $foo. Just like everywhere else in Perl. This consistency makes it easy to learn and easy to debug when it bites. Juerd -- http://convolution.nl/maak_juerd_blij.html http://convolution.nl/make_juerd_happy.html http://convolution.nl/gajigu_juerd_n.html