Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Indirect Object Syntax

by LanX (Sage)
on Nov 06, 2021 at 20:13 UTC ( #11138525=note: print w/replies, xml ) Need Help??


in reply to Indirect Object Syntax

> my @bounds = new GD::Image->stringFT($colour, "Image/outline.ttf", 90, 0.18, 0, 0, $watermark_text);

it's never a good idea to mix two syntax variations

use my @bounds = GD::Image->new->stringFT($colour, "Image/outline.ttf", 90, 0.18, 0, 0, $watermark_text);

Perl wanted to provide maximum flexibility by allowing method syntax from two different language families, this leads to very annoying error messages.

is this

foo bar

  • sub foo(bar()) or
  • bar->foo
?

IMHO indirect object syntax is a good candidate for deprecation.

It could be that only new , print and say will survive.

Avoiding is best, and mixing is a no-no!

update

More in Ch15 of PBP

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^2: Indirect Object Syntax
by Bod (Curate) on Nov 06, 2021 at 20:19 UTC
    my @bounds = new GD::Image->stringFT($colour, "Image/outline.ttf", 90, + 0.18, 0, 0, $watermark_text);
    it's never a good idea to mix two syntax variations
    use my @bounds = GD::Image->new->stringFT($colour, "Image/outline.ttf" +, 90, 0.18, 0, 0, $watermark_text);

    Thanks Rolf,

    I had never realised that I was mixing two different syntaxes...
    It is obvious now that you point it out and I am wondering how I could have not realised up to this point in time!

    That helps a lot 👍

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11138525]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2022-05-26 15:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (93 votes). Check out past polls.

    Notices?