On Tue, Mar 29, 2005 at 06:38:31PM +0200, Juerd wrote:
(B: Luke Palmer skribis 2005-03-29  6:14 (-0700):
(B: >     method iterate () {
(B: >         for (@.objs) {
(B: >             .process($_);   # oops
(B: >         }
(B: >     }
(B: 
(B: There is an alarming similarity with
(B: 
(B:     for (@hashes) {
(B:         .<process>($_)
(B:     }
(B: 
(B: Which doesn't quite use $self! .<>, .[], .{} are method calls, visually,
(B: and should act on the same thing as their unbracketed dot friends.
(B
(BThat only saves one character over this:
(B
(B    for (@hashes) {
(B        $_<process>($_)
(B    }
(B
(B: Subscripting an object is bad style, so $_ for that really is the better
(B: option, I think.
(B
(BThe alternative is for .<>, .[], and .() to be illegal on objects
(Bthat don't support those roles.  Well, okay, there's yet another
(Balternative, which is that these operators are spelled wrong, and that
(Bwe're abusing the idea of . to make it mean too many other things,
(Blike "eat the whitespace before this if it would look like a binary
(Boperator."  Maybe these are actually spelled _<>, _[], and _() in
(Btheir long form.  Have to think about that some.  But using _ instead
(Bof . would more naturally lend itself to defaulting to $_, I think.
(BThe main problem is it doesn't help shorten $_.method.  But maybe
(Bthat's a feature.  Doutless someone will define term _ to mean $_
(Band write _.method, which is of dubious merit.  Or we could use `<>,
(B`[], `(), and `method if we don't use ` for qx.  I daresay `method
(Bwould probably be used more than qx for many styles of programming.
(B
(B: $_ is the topic, and I think that if we have two topics, Perl gets as
(B: convoluted as Japanese for someone who doesn't understand the language.
(B
$B$=$&(B $B$G$9(B $B$M(B...
(B
(B: With loop constructs, the idiomatic syntax for getting a non-$_ is 
(B: "-> $foo", and a similar thing can be done with methods: "($foo:)".
(B: 
(B: But please, let's have a single topic, and let that always be $_. If you
(B: want to access an outer $_, that's $OUTER::_, or its alias, $foo. Just
(B: like everywhere else in Perl. This consistency makes it easy to learn
(B: and easy to debug when it bites.
(B
(BThere will certainly be a single topic.  The only question is whether .
(Bwill ever default to it.  I'm still leaning not.
(B
(BLarry

Reply via email to