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

Re: What's so bad about &function(...)?

by revdiablo (Prior)
on Dec 07, 2005 at 21:28 UTC ( [id://515048]=note: print w/replies, xml ) Need Help??


in reply to What's so bad about &function(...)?

My main objection is cosmetic. I think using the & is ugly. Specifically, I think it's yet another piece of unnecessary syntax. I try to minimize unnecessary syntax as much as possible. It's the same reason I omit parentheses under cases where they're not needed for either precedence or clarity.

Replies are listed 'Best First'.
Re^2: What's so bad about &function(...)?
by Anonymous Monk on Dec 07, 2005 at 21:58 UTC
    It's the same reason I omit parentheses under cases where they're not needed for either precedence or clarity.

    Then you're forcing the maintainers to memorize an operator precedence table to infer your meaning, instead of writing it explictly. At the time you write you code, you know exactly what you mean, and where the parens must go, but you then take away this information in order to promote "consiseness". This is, in my experience, where mistakes tend to happen. I don't think the risk is worth the gain.

    For one thing, I don't think it's worth it to do that much work in stripping down my code. Whenever I find that I've really got too many layers of parens, then I've always found that my code itself is too complex; so I simplify it, or break it into sub-expressions.

    For me, it's all about minimizing the time spent proving the code is correct; if I have to spend time pulling up an obscure table in my memory and cross checking it, there's a chance I'll fuck it up, especially if I'm sick, over-tired, or hungry. Worse yet, I have to carefully cross check code any code that doesn't include parens (and look up that damned table(!)), because I don't know if you were sick, tired, or hungry when you wrote the code, so I don't know if you intended the odd precedence the code may happen to be running with, or if it's a horrible mistake. An explict encoding (and decent comments!) correct both problems.

    Do whatever works best for you, but in my experience, minimizing the number of things I have to think about to get the code right leads to fewer mistakes, and fewer bugfixes six months after I've forgotten about the project and what it's all about.

    --
    Ytrew

      Then you're forcing the maintainers to memorize an operator precedence table to infer your meaning, instead of writing it explictly.

      Notice the word "clarity" in my original sentence. You seem to have missed it the first time through. Or maybe you just didn't understand what I meant. Statements where a maintainer is forced to memorize precedence tables are NOT clear, and hence fall under my "clarity" caveat.

        Notice the word "clarity" in my original sentence. You seem to have missed it the first time through. Or maybe you just didn't understand what I meant. Statements where a maintainer is forced to memorize precedence tables are NOT clear, and hence fall under my "clarity" caveat.

        Sure, but to know if you've omitted the proper set of parenthesis, one still needs to refer to the table, or at least, the subset of it that you consider "clear".

        If you use parenthesis all the time, you don't need to do even that. Depending on how your notion of what "clear" operator precedence is compares to your maintainer's notion, this may or may not lead to actual "clarity". :-)

        --
        Ytrew

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2024-04-19 09:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found