In the hope this saves Allison time, and/or
clarifies things for me, I'll attempt some
answers.

> In your article at perl.com you describes
> various ways and situations when perl
> creates a topic and this is described as
> perl making the following binding on my behalf: 
> 
> $_ := $some_var ;  *1*

Well, $_ might not be bound to a named variable
but instead be just set to a value, or it might
be bound to an array cell or some other unnamed
container.


> is *1* _all_ that topic is about ?

Sorta. To quote an excellent summary:

    "Topic is $_". 


> my $x,$z;
> given $x->$y {
> $_ := $z ; 
> when 2 { ... } #checks against $z ???
> }

Yes.


> methods topicalize their invocant. Is $self
> aliased to $_ inside the method in this ex. ?
> 
>     method sub_ether ($self: $message) {
>         .transmit( .encode($message) );
>     }

Yes.


> will it be an error to write 
>     method sub_ether ($self: $message, $x is topic) {...} 

No.


> what happens if I write 
>     method sub_ether ($self: $message) {
> $_ := $message ; 
> } 
> or 
> 
> method sub_ether ($self: $message) {
> $_ = $message ; 
>  }

Both Ok. $_ is "it" and has the value $message;
in the former case $_ and $message are bound.


> is $_ always lexical variable.

Yes.


> Or I can have $MyPackage::_ ?

You can copy or alias any value.


> * can I alias $something to $_ ? 
>   $something := $_ 

Sure. Because...

> (it seems that I can , because $_ is just
> another variable )



> $b := $a ; 
> $c := $b ; 
> 
> ( now changing value of one variable will
> change other two ??? )

Yes.


> or e.g. 
> 
> $a = 1 ; 
> $Z = 10 ;
> 
> $b := $a ; 
> $c := $b ; 
> 
> print $c # prints 1 
> $a := $Z ; 
> print $c # prints 10
> $a = 5; 
> print $Z # prints 5 

Yes.


> also 
> 
> @a :=  ( $a, $b) 

Er, I don't think (it makes sense that) you
can bind to a literal.

> $b := $c 
> @a[1] = 10 ; 
> print $c # prints 10 

Lost you there, even ignoring the literal issue.

--
ralph

Reply via email to