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

Re: SURPRISE(?): return() VS other builtin()s

Thread Previous | Thread Next
Rafael Garcia-Suarez
August 4, 2008 05:27
Re: SURPRISE(?): return() VS other builtin()s
Message ID:
2008/8/3 Tom Christiansen <>:
> Now for my questions regarding the (un)compiled forms:
>    5. Are you surprised to see the file-scoped lexical pragmata
>       explicitly propagated down into each subroutine?

Yes, since I thought I coded around this. But apparently I overlooked the fact
that deparse_root localizes deparsed hints, which then are not "seen" by

The following trivial patches fixes this, but obviously needs more testing.
Those lines were probably useful in the past. They may still be.

--- ext/B/B/	2008-06-17 16:40:04.000000000 +0200
+++ lib/B/	2008-08-04 14:11:12.000000000 +0200
@@ -1176,8 +1176,6 @@
 sub deparse_root {
     my $self = shift;
     my($op) = @_;
-    local(@$self{qw'curstash warnings hints hinthash'})
-      = @$self{qw'curstash warnings hints hinthash'};
     my @kids;
     return if null $op->first; # Can happen, e.g., for Bytecode without -k
     for (my $kid = $op->first->sibling; !null($kid); $kid = $kid->sibling) {

>    6. Notice how compiler preserves only the refs stricture for
>       the interpreter to regard.  This makes some sense, as the
>       vars and subs strictures are a compile-time thing only,
>       whereas refs is runtime.
>       My concern is this: lexical pragmata are supposed to propagate
>       into an eval "STRING" construct, which must first compile
>       the STRING code.  If we record only strict refs, despite
>       having said use strict, are the other two lost, and if not,
>       why not?

Those flags are stored in the op_targ field of the entereval op.
See function Perl_ck_eval in op.c. So they're not lost in an eval STRING.

The core, and thus B::Deparse, should now be able to handle other
pragmas than those mentioned in the documentation. I think that
all that's needed to get full support to deparse "use strict" is this
trivial patch : (besides tests and docs, that is)

--- ext/B/B/	2008-06-17 16:40:04.000000000 +0200
+++ lib/B/	2008-08-04 14:23:41.000000000 +0200
@@ -1484,6 +1482,8 @@
     push @pragmas, "integer" if $bits & 0x1;
     push @pragmas, "strict 'refs'" if $bits & 0x2;
     push @pragmas, "bytes" if $bits & 0x8;
+    push @pragmas, "strict 'subs'" if $bits & 0x200;
+    push @pragmas, "strict 'vars'" if $bits & 0x400;
     return @pragmas;

But 'tis evident to me, when they affirm, 'That they who have seen Paris,
have seen every thing,' they must mean to speak of those who have seen it
by day-light. -- Laurence Sterne, Tristram Shandy

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