develooper Front page | perl.perl5.porters | Postings from April 2007

Re: idea for yet another LNV and caller() return value (was: The Strict trap)

Thread Previous | Thread Next
From:
David Nicol
Date:
April 25, 2007 14:47
Subject:
Re: idea for yet another LNV and caller() return value (was: The Strict trap)
Message ID:
934f64a20704251447w16527080j2e5ce813f6ce8b30@mail.gmail.com
On 4/25/07, Artur Bergman <sky@crucially.net> wrote:
> > there is a problem
> >
> > BEGIN {
> >  import()
> > }
> >
> > is two scopes
> >
> > though you could just walk the destructor stack I guess and insert it
> > on the right place, it is quite simple
> >
> > artur

Exactly.

lets say the new Hook::Scope hook is called POST_OUTER, and it has a &;$
or a $& prototype, where the scalar represents how many scopes out to walk.
Adding an optional count after the code in the existing POST hook would work.

So for forward compatibility, do we:

 (1) commit to keeping C<use> having
an implied scope, which means we can go ahead and document that lexicals
delcared in the arguments to use

       use superdupervariable my $SDV;

will immediately disappear (RGS rejected such a doc patch, saying that the right
thing to do would be to fix the problem)

(2) add special provision for the situation so that the scope walker will skip
implied scopes, which might be the best situation due to the other situations
where scopes get implied, and also where they get optimized away some kind
of note could be kept so that POST would respect optimized-away scopes
when decrementing its pedometer

(3) fix C<use> by creating a "scopeless BEGIN"  -- which is not a bad idea
in itself; using rounds instead of curlies would do the job, at a language
syntax level; I don't know how difficult that would be to parse -- anyone whose
code breaks because they named a subroutine BEGIN could be
considered to have been asking for it --

(4) not touch the scopes and document

      POST { no ModuleFoo } 2;

as something that works now but could conceivably break, and that there are
other weirdnesses with scope counting where the count for the post hook will
not exactly match the curlie count in the text, and that these might change
between versions.


are POST hooks currently FIFO or LIFO?  LIFO would be preferable IMO
-- 
practical solutions to systemic problems

Thread Previous | Thread Next


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