I hate indirect object syntax. I think its an unnecessary confusion just to support new Class. It doesn't really work for anything else as English sentence structure is subject then verb. Even new Class @args falls apart.
That's style, and style can be endlessly argued. This can't.
use Test::More tests => 1;
sub Foo::bar { 23 }
ok Foo->isa("bar")
Can't locate object method "ok" via package "Foo" at -e line 1.
Grammatical ambiguity to support new Class. GRAH! -> is the second highest precedence operator and should take precedence over indirect object syntax. Worse, the meaning of ok Foo->isa("bar") changes whether or not the Foo symbol table has entries at compile time.
It's even more fun in DESTROY methods (Score:1)
A couple years ago I tracked down a bug in DBIx::Librarian [cpan.org] where database handles were hanging around and causing trouble. Granted, the context I was using it in wasn't straight forward, but here's what the fix turned out to be:
The author turned around a new release really fast, but it's a reminder to me to always use the direct syntax.
couldn't agree more (Score:2)
@JAPH = qw(Hacker Perl Another Just);
print reverse @JAPH;
Doc Patches (Score:1)
My favorite is reading code at Perl Monks that mixes different constructor invocation styles.
Are you up for patching the documentation of the most egregious offenders? I can think of a few places in the Perl core that need re-education.
problem is (Score:1)
use Test::More tests => 1;
sub Foo::bar { 23 }
ok can Foo "bar"
The Fix (Score:2)
As an aside for anyone reading this who didn't know it, you can fix this with a unary plus:
But yet, indirect object syntax is very, very annoying.
My only use of it (Score:1)
new Object(...);
throw Exception(...);
throw me (Score:1)
throw My::Exception('Boom!');
I should really get our of that habit. Then the game would be complete.