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

Re: Indirect object syntax

Thread Previous | Thread Next
From:
Lukas Mai
Date:
May 30, 2016 19:04
Subject:
Re: Indirect object syntax
Message ID:
ef4e0d9b-587e-dc19-b533-4a1a708c1fda@gmail.com
Am 26.05.2016 um 07:02 schrieb Aristotle Pagaltzis:
> * 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.

A similar failure mode I've encountered in the past:

use Test::More;
...
like Some::Module->new(...)->as_string, qr/.../;

Which parses as:

Some::Class->like->new(...)->as_string, qr/.../;

-- 
Lukas Mai <plokinom@gmail.com>

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