Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

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

by LanX (Archbishop)
on Dec 29, 2015 at 09:56 UTC ( #1151366=note: print w/replies, xml ) Need Help??


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 (Pope) on Dec 29, 2015 at 10: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.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2019-06-26 18:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Is there a future for codeless software?



    Results (111 votes). Check out past polls.

    Notices?