Front page | perl.perl6.language |
Postings from May 2005
Re: (1,(2,3),4)[2]
Thread Previous
|
Thread Next
From:
Juerd
Date:
May 26, 2005 02:30
Subject:
Re: (1,(2,3),4)[2]
Message ID:
20050526093009.GE31996@c4.convolution.nl
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.
> 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.
Juerd
--
http://convolution.nl/maak_juerd_blij.html
http://convolution.nl/make_juerd_happy.html
http://convolution.nl/gajigu_juerd_n.html
Thread Previous
|
Thread Next