Re: [code-review] Re: Lingua::Phonology

"Mark Dominus" <[email protected]> Thu, 13 Nov 2003 10:58:52 -0500
Newsgroups gmane.comp.lang.perl.code-review-ladder
Message-ID <[email protected]>
"Hodges, Paul" <[email protected]>:
> As a more serious question, why "try to avoid the 'indirect object'
> syntax for methods"? 

As I said, I think the semantics is just too complicated and unreliable.

Why I mean by this is that the indirect object syntax is ambiguous.
Every indirect object call could potentially mean two different things.
It means two different things.  If you write

        $self->{SYMBOLS} = new Lingua::Phonology::Symbols $self->{FEATURES};

it might be interpreted as

        $self->{SYMBOLS} = Lingua::Phonology::Symbols->new($self->{FEATURES});

which is usually what you intended, but it might also be interpreted as

        $self->{SYMBOLS} = new(Lingua::Phonology::Symbols($self->{FEATURES}));

which is totally different.  

The locution is fragile: which interpretation is chosen by Perl can
change suddenly and unexpected when a piece of code far away is
changed.

The locution is complicated: I would venture to guess that nobody on
this list knows offhand what the rules are that determine which
interpretation will chosen. 

So the general rule about prefering the simple and robust to the
complicated and fragile says to avoid the indirect object syntax
whenever possible.