Front page | perl.perl6.internals |
Postings from July 2002
Re: [perl #15800] [PATCH] lexical scope ops, test and example
From:
Jonathan Sillito
Date:
July 30, 2002 10:04
Subject:
Re: [perl #15800] [PATCH] lexical scope ops, test and example
Message ID:
1028048504.2786.15.camel@localhost.localdomain
Thanks for the correction. May I ask about the find_lex op? In my
implementation it looks back through the stack of pads for the given
lexical:
new P0, .PerlInt
new P1, .PerlInt
set P0, 10
open_lex
store_lex P0, "a"
# nested lexical scope
open_lex
find_lex P1, "a"
print P1 # prints 10
# etc
Also, should open_lex/close_lex be named new_pad/close_pad instead?
If you want to hold off on applying the patch, I will submit one with
the correct semantics in the next couple of hours. Or if you have
already submitted it I will send a patch to fix it.
Thanks again.
--
Jonathan Sillito
On Tue, 2002-07-30 at 10:47, Melvin Smith wrote:
> See my 2 comments:
>
> > new P0, .PerlInt
> > new P1, .PerlInt
> > new P2, .PerlInt
> > new P3, .PerlInt
> > set P0, 10
> > set P1, 11
> > set P2, 12
> >
> > # outer most lexical scope
> > open_lex
> ^^^^^^^^ New pad
> > store_lex P0, "a"
> > find_lex P3, "a"
> > print P3 # prints 10
> > print "\n"
> >
> > # nested lexical scope
> > open_lex
> > store_lex P1, "b"
> > find_lex P3, "b"
> > print P3 # prints 11
> > print "\n"
> >
> > store_lex P2, "a" # overwrites previous "a"
> ^^^^^^^^^^^^^^^^^ Should not "overwrite", should shadow since it is
> stored
> in the current pad
> > find_lex P3, "a"
> > print P3 # prints 12
> > print "\n"
> >
> > close_lex # end of nested lexical scope
> ^^^^^^^^^ Pad goes away, with "b" and "a", so the outer values
> should be back in effect.
> >
> > find_lex P3, "a"
> > print P3 # prints 12
> > print "\n"
> > end
>
> I'll apply this, since it is clean, but the semantics need adjustment.
> Thanks,
>
> -Melvin Smith
>
> IBM :: Atlanta Innovation Center
> melvins@us.ibm.com :: 770-835-6984
>