I just want to be sure I understand correctly :
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*
and probably marking $_ with some additional properties (e.g. is
read-only ...) .
questions:
???
if I will write that explicitly myself will that have *the same*
effect ? in other words, is *1* _all_ that topic is about ? Or there
is some additional magic. particularly , will "when" work as before ,
What will happen if I will _override_ $_ explicitly inside
e.g. "given" construct or other topicalizers:
my $x,$z;
given $x->$y {
$_ := $z ;
when 2 { ... } #checks against $z ???
}
???
methods topicalize their invocant. Is $self aliased to $_ inside the
method in this ex. ?
method sub_ether ($self: $message) {
.transmit( .encode($message) );
}
will it be an error to write
method sub_ether ($self: $message, $x is topic) {...}
what happens if I write
method sub_ether ($self: $message) {
$_ := $message ;
}
or
method sub_ether ($self: $message) {
$_ = $message ;
}
is $_ always lexical variable. Or I can have $MyPackage::_ ?
and just on the related topic :
* can I alias $something to $_ ?
$something := $_
(it seems that I can , because $_ is just another variable )
also , is this valid ?
$b := $a ;
$c := $b ;
( now changing value of one variable will change other two ??? )
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
am I wrong ?
also
@a := ( $a, $b)
$b := $c
@a[1] = 10 ;
print $c # prints 10
???
thanks
Arcadi