Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: To parens or not parens in chained method calls

by GrandFather (Saint)
on Feb 16, 2017 at 22:57 UTC ( [id://1182177]=note: print w/replies, xml ) Need Help??


in reply to To parens or not parens in chained method calls

Interesting question. The compelling criteria for me is consistency. A function/method call is a function/method call regardless of the number of parameters passed. So I include the () even if no parameters are passed in the call.

However, like Athanasius I use the Perl built in functions like length without parens. If pressed for a justification for the inconsistency I'd suggest functions like length are more like operators.

Very likely my long C++ experience biases what "looks right" to my eye in this case. My path to my current Perl style almost exactly mimics Athanasius's tale. I would make pretty much the same arguments, except in this small case where I'd apply the "make things that are the same look the same" rule - a call is a call regardless of the number of parameters.

Premature optimization is the root of all job security

Replies are listed 'Best First'.
Re^2: To parens or not parens in chained method calls
by stevieb (Canon) on Feb 17, 2017 at 00:45 UTC

    My main reason for considering not using empty parens (beyond doing it for built-ins), is I never thought about it before. I've always loved Perl, but because there's enough noise, if I could reduce some, I would (it took several years before I came up with a 'standard'). Before Perl, I didn't have much devel experience less some at-home C++ Windows fun I was having when I bought (yep, bought) Borland C++ Builder, and a book to learn from.

    That doesn't count though. Perl is where I learned how to program, now I can understand (in some cases at a basic level) several languages. I'm very proficient in Perl and Python, I believe I'm starting to understand C to the point I can compile relatively reasonable complex code and know when the compiler will barf, and I can finagle and mingle with C# and some C++, and can just get by in JS/JQuery.

    My objective, thanks to what Your Mother said, is now relevant across all languages I frequent, which I didn't think of when I wrote my OP. Now, with the way that things are explained here (in your reply) and other parts of this thread, I may need to step back, consider everything outlined in this thread, and consider the ramifications in all langs, *then* come up with a favoured method.

    Funny how such a simple question could have such far-reaching potential ramifications.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-03-28 15:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found