develooper Front page | perl.perl5.porters | Postings from May 2016

Re: Indirect object syntax

Thread Previous | Thread Next
From:
Aristotle Pagaltzis
Date:
May 26, 2016 05:02
Subject:
Re: Indirect object syntax
Message ID:
20160526050244.GA91318@plasmasturm.org
* Abigail <abigail@abigail.be> [2016-05-25 20:23]:
> It's only useful for people who don't want indirect object syntax in
> their programs, but somehow use it anyway.

Just today I wrote this:

    my $href = html_escape URI->new_abs( '..', $selflink );

Except no, that doesn’t work, because Perl thought I meant this:

    my $href = URI->new_abs( '..', $selflink )->html_escape;

Perl didn’t tell me (and why should it?), so I only found out when I ran
that code and it died for lack of a URI->html_escape method.

So then I had to rewrite it as either of these:

    my $href = html_escape +URI->new_abs( '..', $selflink );
    my $href = html_escape( URI->new_abs( '..', $selflink ) );

… both of which are irritating.

The current `no indirect` would at least have warned me. And if I could
tell the parser to never interpret anything as an indirect method call,
I could avoid adding noise to the code.

So it is indeed only useful for people who don't want indirect object
syntax in their programs, but somehow use it anyway – which is most of
them.

Regards,
-- 
Aristotle Pagaltzis // <http://plasmasturm.org/>

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About