develooper Front page | perl.perl6.internals | Postings from July 2002

Re: [perl #15800] [PATCH] lexical scope ops, test and example

Jonathan Sillito
July 30, 2002 09:19
Re: [perl #15800] [PATCH] lexical scope ops, test and example
Message ID:
On Mon, 2002-07-29 at 17:12, Simon Glover wrote:
>  I think you forgot to attach the patch...

oops, now the files are attached ...
 - patch: lex.patch
 - test file: lexicals.t
 - example file: lexicals.pasm

On Tue, 2002-07-30 at 02:14, Stephen Rawls wrote:
> --- Jonathan Sillito 
> >     close_lex # end of nested lexical scope
> > 
> >   find_lex P3, "a"
> >   print P3 # prints 12
> >   print "\n"
> >   end
> > 
> That's a typo, right?  It should print the first value
> of "a" (10).  Just making sure I'm not crazy ...

Hey, thanks for reading this over. It is not a typo, but it may be
incorrect. My code does overwrite previous lexicals in enclosing scopes
(i.e. lexicals in pads lower on the stack), but maybe I have the
semantics of the store_lex op wrong? The following example shows what I
had in mind:

  my $x = 13;

  sub foo 
    $x = 12;

  print $x; # prints 12

The alternative (what you have in mind I guess) is:

  my $x = 13;

  sub foo 
     my $x = 12; # notice the my

  print $x; # prints 13

So I guess I see your point. Let me know if I should change the
implementation (it would be a quick change). Also note that there is
currently no support for accessing lexicals by index or for creating
pads from descriptors.

Thanks for any comments.
Jonathan Sillito Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About