develooper Front page | perl.perl5.porters | Postings from September 2000

Re: [ID 20000828.017] bytecode fails with use subs;

Thread Previous | Thread Next
Nicholas Clark
September 28, 2000 03:52
Re: [ID 20000828.017] bytecode fails with use subs;
Message ID:
On Tue, Aug 29, 2000 at 04:57:46PM +0100, Nicholas Clark wrote:
> On Tue, Aug 29, 2000 at 07:18:40AM -0700, Benjamin Stuhl wrote:
> > I'm not entirely sure where to go. One option (read:
> > (possibly evil) hack) is to have store a list
> > (perhaps @B::Bytecode::Savelist) of what it's creating and
> > have B::Bytecode look at that to see what subs that it
> > would normally ignore should actually should be saved.
> This seems both evil and slow :-(
> My understanding is that  Evil is allowed if it has the saving grace

Simon Cozens and I had a chat at YAPC::Europe, and concluded that the correct
solution was to turn off the GvIMPORTED_CV flag on a gv when the subroutine
was defined. Hopefully this patch is the correct implementation of this.]

This works for the common case of:

use subs qw(foo);
sub foo {
  print "This is foo\n";

(which didn't before)


sub bar {
  print "This is bar\n";
use subs qw(bar);

still doesn't work. I guess it still needs sv.c not to set the GvIMPORTED_CV
flag if you're importing from yourself to yourself.
(simply to propagate any flag you find)

However, with the patch one can now byte-compile the use subs; in perlcc

Nicholas Clark

--- op.c.orig   Thu Sep 14 15:44:20 2000
+++ op.c        Wed Sep 27 21:51:04 2000
@@ -4561,6 +4561,9 @@
     CvGV(cv) = (GV*)SvREFCNT_inc(gv);
     CvFILE(cv) = CopFILE(PL_curcop);
     CvSTASH(cv) = PL_curstash;
+    /* use subs; etc may have turned this on
+       As we're (re)defining the sub here it's definately not imported */
+    GvIMPORTED_CV_off(gv);
     CvOWNER(cv) = 0;
     if (!CvMUTEXP(cv)) {

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