Em Seg, 2009-05-25 às 11:36 -0500, John M. Dlugosz escreveu: > Can you tell me if I'm missing something fundamental here?
While I'm not larry, I think I can help you out here ;) > Regarding "item containers" ... > my @A = (1, 2, 3); > my $x; # default to "is Scalar" > $x = @A; '$x' is the name of a variable that is in the lexpad. The sigil is part of the name, and means little at runtime... The sigil is only important at compile time for explicit context sensitiveness. So, at the end of this snippet, the lexpad contains a scalar stored at the name '$x', which then holds the array inside its "cell". A few facts: * A Scalar in item context returns its value; * The dotty operator implies item context; * A list in item context returns itself; so... what happens, in detail, in the above snippet is: * an Array X is created and stored in the lexpad as the name '@A' * The contents of the list (1,2,3) is iterated, copying the values to the Array X; * an Scalar Y is created and stored in the lexpad as the name '$x' * The name '@A' is resolved to the Array X, which is used in item context, returning itself * The Scalar Y receives the rvalue to be STOREd in its cell. > Now $x is BOUND TO an item container of type Scalar, which CONTAINS an > Array which itself CONTAINS 3 items of type Int. Exactly. but it would probably be more clear to state that "the name '$x' in the lexpad is bound to a item container", binding is something that happens to the variable as stored in the lexpad, so it's an operation that happens in the lexpad, not in the container... (that simplifying the point where the lexpad is also a container) > @A is BOUND TO a list container of type Array. > my $y := @A; > $y is BOUND TO the Array, same as @A is. Again, binding to a variable is an operation in the lexpad, much the same way as: %a<b> := 1; is an operation in the hash itself, not in that specific cell of the hash. daniel