in reply to Re^4: ... for (@_) x= 2; (scalar assignment)
in thread ... for (@_) x= 2;

It's one of these DWIM edge case implementations which make Perl less orthogonal. :-/

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

  • Comment on Re^5: ... for (@_) x= 2; (scalar assignment)

Replies are listed 'Best First'.
Re^6: ... for (@_) x= 2; (scalar assignment)
by ikegami (Patriarch) on Dec 29, 2015 at 15:07 UTC

    It's not an edge case. It's consistent with all `OP=` operators.

    The reason is simple: You can't evaluate an expression as a boolean and as a list.

      > It's consistent with all `OP=` operators.

      You are missing the point, this sub-thread is talking about x not x=

      How many operators do you know which depend on the LHS being in brackets or not?

      Cheers Rolf
      (addicted to the Perl Programming Language and ☆☆☆☆ :)
      Je suis Charlie!

        Ah, ok.

        I know three cases where parens matter (aside from when they override precedence or disambiguate syntax):

        • (...) = ... vs ... = ...
        • (...) x ... vs ... x ...
        • eof vs eof()

        I think there's another one.

        For the first two, it was either that or create a new operator. No other operators behave differently based on whether one their operand is list-like or not. It's a pity = and x didn't adopt the same definition of list-like, but then again, one expects lvalues and the other expects rvalues.