in reply to Re^2: What is the + in +shift doing here?
in thread What is the + in +shift doing here?

There's nothing "more clear" about shift(@_). We're talking about disambiguating something; to make it clear that it's a function call, parentheses make the most sense. There is nothing ambiguous about leaving the argument implicit, and there's certainly nothing alarming about using implicit variables, just as there's nothing alarming about omitting the parentheses. But using a + instead of the parentheses is economy at the expense of clarity, which is alarming.

The coward posts anonymously, then logs in to downvote the response.

Replies are listed 'Best First'.
Re^4: What is the + in +shift doing here?
by Anonymous Monk on Feb 24, 2005 at 16:35 UTC
    to make it clear that it's a function call, parentheses make the most sense.
    Really? That's something uniformly agreed on? People write +shift for the purpose of being unclear?

    I disagree. I couldn't care less whether you find parentheses or unary minus more or less clear, or what makes the most sense to you. But you will find me disagreeing with you each and every time you make such statements as if they are undeniable universal truths.

    But using a + instead of the parentheses
    It's not instead of parentheses. It's instead of using an argument. Or using it in a longer expression. Or instead of parenthesis around the function call. It's just one of many ways to make it not like a bareword.
      Really? That's something uniformly agreed on?
      Yes. Parentheses connote a function call. + does not.
      People write +shift for the purpose of being unclear?
      No, and I didn't say they did. They write + to be economical. The side-effect is that they are less clear.
      you will find me disagreeing with you
      That might carry some weight if you were a real Perl Monk with some reputation of your own, instead of someone hiding behind Anonymous.

      If you want to quibble about what it's instead of, it's instead of writing something that connotes a function call.


      Caution: Contents may have been coded under pressure.

        I would write shift(@_) (or, in some cases, shift @_), because I've seen too many cases where it was hard to even find where the argument handling was being done is some complex subroutines. It is nice to only search for @_ and $_[ vs. also having to search for shift without an argument or pop without an argument (the "without an argument" complicates such a visual scan considerably). Well, and I just find avoiding 2 characters to be a silly choice when it reduces code clarity.

        - tye