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

[perl #129916] CV symbol table optimization only works in main::

Thread Previous
From:
Father Chrysostomos via RT
Date:
August 29, 2017 03:33
Subject:
[perl #129916] CV symbol table optimization only works in main::
Message ID:
rt-4.0.24-23212-1503977635-365.129916-15-0@perl.org
On Wed, 19 Oct 2016 07:20:42 -0700, mauke- wrote:
> 
> This is a bug report for perl from l.mai@web.de,
> generated with the help of perlbug 1.40 running under perl 5.24.0.
> 
> 
> -----------------------------------------------------------------
> [Please describe your issue here]
> 
> Here's the merge I'm talking about:
> http://perl5.git.perl.org/perl.git/commitdiff/f9d9e965
> 
> Also listed in perl5220delta:
> 
> Subroutines in packages no longer need to be stored in typeglobs:
> declaring a subroutine will now put a simple sub reference directly in
> the stash if possible, saving memory.
> 
> This works fine for the main script:
> 
> $ perl -wE 'sub foo { 42 } say $main::{foo}'
> CODE(0xa06f668)
> 
> But not in other packages:
> 
> $ perl -wE 'package Other; sub foo { 42 } say $Other::{foo}'
> *Other::foo
> 
> I.e. this optimization doesn't apply to modules, which is where most
> subroutines come from.

Fixing it causes this to fail:

	use Test::More tests => 1;

	package Other;

	sub f1 { "f1" }
	local $Other::{"f1"} = sub { "h1" };
	::is(f1(), "h1", "localised sub via stash");

Does this matter?  This is pretty obscure code (from t/op/local.t) that should probably be doing local *Other::f1 = sub { "h1" } instead (if it were production code).

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=129916

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About