Micholas Clarke asked:

If a subroutine explicitly needs access to its invocant's topic, what is so
wrong with having an explicit read-write parameter in the argument list that
the caller of the subroutine is expected to put $_ in?
Absolutely nothing. And perfectly legal. You can even call that rw parameter $_
if you like:

	sub get($id_obj, $_ is rw) {
	    when "who"     { return $id_obj.name }
	    when "choose"  { return any($id_obj.features).pick }
	    when "all"     { return $id_obj.features }
	}

	for «name choose all» {
	    print get($obj, $_);
	}


If I understand all this correctly, as is, this "access caller's topic"
is an unrestricted licence to commit action at a distance.
Yes. As in Perl 5.


Accessing the caller's topic is the default in perl5. And there is still a
steady stream of bugs to p5p where core perl modules are doing something
(typically a while loop) which tramples on $_, and so makes something go
wrong in their caller. (possibly several levels down)
Yes. That's why it's not the default in Perl 6, and you have to specify
a verbose and slightly ungainly property in order to get the behaviour.



Damian

Reply via email to