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.
A couple years ago I tracked down a bug in DBIx::Librarian 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:
sub DESTROY {
my ($self) = @_;
- disconnect $self if $self->is_connected;
+ $self->disconnect if $self->is_connected;
}
The author turned around a new release really fast, but it's a reminder to me to always use the direct syntax.
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.
As an aside for anyone reading this who didn't know it, you can fix this with a unary plus:
ok +Foo->isa("bar");
But yet, indirect object syntax is very, very annoying.