On 10-06-06 10:49 AM, Philip Potter wrote:
On 6 June 2010 14:37, Shawn H Corey<[email protected]>  wrote:
On 10-06-06 09:06 AM, Chas. Owens wrote:

But that is not the problem; autovivification will create the references:

perl -MData::Dumper -le '$c->[0]{a}; print Dumper $c'


But that is the problem.  Autovivification should not happen for r-values,
only l-values.

I take it you mean it should only happen when you write to a location
($c->[3] = 'foo') not when you read from a location (print $c->[3]) ?
I would think that $c->[0]{a} is an lvalue by most definitions - it's
a value which can be written to. It's an lvalue even when on the right
side of an assignment.

Yes, although the names are taken from whether they appear on the left or right of a simple assignment, what they are depends on whether a value is assigned. In the Perl one-liner above, they are all r-values. Now consider:

$c->[$a[$index]]{a} = $count++;

R-values in the above:
$c
$index
$a[$index]
'a'
$c->[$a[$index]]
$count

L-values:
$c->[$a[$index]]{a}
$count

As you can see, things can get complicated very quickly.


--
Just my 0.00000002 million dollars worth,
  Shawn

Programming is as much about organization and communication
as it is about coding.

The secret to great software:  Fail early & often.

Eliminate software piracy:  use only FLOSS.

--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/


Reply via email to