develooper Front page | perl.perl5.porters | Postings from December 2017

Re: [perl #132588] In-place sort does not kill weak refs

Thread Previous | Thread Next
December 15, 2017 22:41
Re: [perl #132588] In-place sort does not kill weak refs
Message ID:
Father Chrysostomos wrote:
>$ perl5.27.7 -le 'use Scalar::Util "weaken"; weaken ($a = \$_[0]); @_ = sort @_; print $a; print \$_[0]'

After coming up with blessedness and then tiedness, I was wondering what
other kinds of magic might be applied to an array element, and how sort
would need to treat them.  This one confirms that in general sort needs
to take the slow path for any kind of magic.  We don't distinguish between
magic that's part of the container and magic that's part of the value, but
we have little of the latter, so wouldn't lose much by not catering to it.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About