in reply to Re: OO style: Placement of "new"
in thread OO style: Placement of "new"

I fail to see any actual prohibition in that section, at least, not on class methods. To be honest, most of what's said in that section doesn't even belong in there. The only warning I actually spot against it there, is on that "parens around all parameters" thing:
new Critter ('Bam' x 2), 1.4, 45
However, that's precisely the same problem you get when you do
print ('Bam' x 2), 1.4, 45;
so that's nothing new.

OTOH, the one problem I did notice with this "indirect object method", is that it doesn't work with perl's built-in keywords — and likely other predefined subs as well, so the next doesn't call the method "open" in the class "ReadFile":

my $handle = open ReadFile($file);
Instead, you have to use
my $handle = ReadFile->open($file);
I guess that falls under "the same ambiguity as ordinary list operators", in perlobj.

Replies are listed 'Best First'.
Re: OO style: Placement of "new"
by Abigail-II (Bishop) on Apr 08, 2003 at 09:48 UTC
    The problem isn't precedence. The problem isn't keywords either. The problem is that
    new Foo;

    might call either of

    &new ('Foo'); # Calling new in the current package

    or

    Foo -> new (); # Calling new in Foo, or a parent class

    And there are a bunch of cases that decide which one it will be.

    And no, Perl doesn't like "prohibitions". You are free to do whatever you fancy. But the documentation does give advices on how not to get hurt.

    Abigail