develooper Front page | perl.perl6.language | Postings from May 2005

Re: (1,(2,3),4)[2]

Thread Previous | Thread Next
From:
Rod Adams
Date:
May 26, 2005 11:03
Subject:
Re: (1,(2,3),4)[2]
Message ID:
42960F50.4080301@rodadams.net
Juerd wrote:

>Rod Adams skribis 2005-05-26  4:15 (-0500):
>  
>
>>From S02: "Array and hash variable names in scalar context 
>>automatically produce references."
>>Since [...] produces a scalar arrayref, we end up with an arrayref one 
>>both sides of the =.
>>    
>>
>
>No.
>
>There is no scalar context on the LHS of the assignment operator.
>
>And, assigning to a reference is impossible, as a reference is a VALUE,
>not a VARIABLE (container).
>
>Assigning to a reference thus makes no sense in the same way that
>assigning a new value to the number 42 makes no sense. It is possible
>with some tricks, but you really shouldn't ever want to do this.
>
>  
>

You're right. It was late, and my brain missed a few details. I saw 
"arrayref = arrayref", and C took over.

>>If I understand Juerd correctly, the logical extension would be to have
>>   @m = 5;
>>be the same as:
>>   @m = list(5);
>>    
>>
>
>The RHS of an array assignment is in list context. "list" is an operator
>that does nothing more than force list context. In this case, it is
>entirely redundant. But, of course, valid.
>  
>

Of course it works that way. Why else would there be a want() function?


-- Rod Adams

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About