Re: Question for Larry

2009-05-26 Thread TSa

HaloO,

John M. Dlugosz wrote:

Daniel Ruoso daniel-at-ruoso.com |Perl 6| wrote:

  %ab := 1;

is an operation in the hash itself, not in that specific cell of the
hash.


This to me implies that postcircumfix:{'',''} returns some
assignment proxy that knows the hash. This is e.g. needed for
autovivification which happens in lvalue context but not in
rvalue context.


  


What?


Nothing in S02, S03 or S06 suggests such a usage.  := is used to alias a 
name  The expression on the left does not name a variable, but is an 
expression.


I would think that binding is the high level equivalent to pointer
assignment. Since %ab is a proper lvalue binding can just assign
the lvalue from the right hand side to the left. Daniel's statement
above implies that the hash providing the lvalue location is involved
in this process. I would expect that

   my $x = 'foo';
   my %ab := $x; # does \$x work as well?
   %ab = 'from hash';
   say $x; # prints 'from hash'

works as indicated. Note that Perl 6 dropped the Perl 5 references.
%ab = \$x is still valid syntax but stores a capture of $x which
is not modifiable, IIRC. Or would the code sequence above work also
with a capture instead of binding?


Regards, TSa.
--

The unavoidable price of reliability is simplicity -- C.A.R. Hoare
Simplicity does not precede complexity, but follows it. -- A.J. Perlis
1 + 2 + 3 + 4 + ... = -1/12  -- Srinivasa Ramanujan


Question for Larry

2009-05-25 Thread John M. Dlugosz

Can you tell me if I'm missing something fundamental here?

Regarding item containers ...

   my @A = (1, 2, 3);
   my $x;  # default to is Scalar
   $x = @A;

Now $x is BOUND TO an item container of type Scalar, which CONTAINS an 
Array which itself CONTAINS 3 items of type Int.


@A is BOUND TO a list container of type Array.

   my $y := @A;

$y is BOUND TO the Array, same as @A is.

--John



Re: Question for Larry

2009-05-25 Thread Daniel Ruoso
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:

  %ab := 1;

is an operation in the hash itself, not in that specific cell of the
hash.

daniel



Re: Question for Larry

2009-05-25 Thread John M. Dlugosz

Daniel Ruoso daniel-at-ruoso.com |Perl 6| wrote:

A few facts:

* A Scalar in item context returns its value;
* The dotty operator implies item context;
* A list in item context returns itself;

  

Thanks.



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...
  
I think you're agreeing with me.  True, by $x I meant the symbol as 
resolved to a particular scope.  lexpad is not mentioned in the 
synopses.  Behaviorally, the symbol table such as MY:: or some package 
appears to be a hash that associates the declared name with the container.




(that simplifying the point where the lexpad is also a container) 

  

That I don't follow.



  %ab := 1;

is an operation in the hash itself, not in that specific cell of the
hash.
  


What?


Nothing in S02, S03 or S06 suggests such a usage.  := is used to alias a 
name  The expression on the left does not name a variable, but is an 
expression.


--John