Actually, I suppose I should clarify what I want to get at here, which is
when lexical pads popped off the stack. Am I responsible for cleaning up
any lexical pads I push on the stack? (I assume I am, but just wanted to
be sure) ie) If I'm in a subroutine that just pushed a lexical pad on the
stack and an exception gets thrown, do I have to catch the exception, pop
the pad off the stack, and then rethrow the exception?
Cory
Is there currently any method of determining the depth of the lexical
scope pad stack? None of the ops in var.pod seem to be able to provide
that information at the moment...
Cory
>> Is there currently any method of determining the depth of the lexical scope
>> pad stack? None of the ops in var.pod seem to be able to provide that
>> information at the moment...
You can query the pad depth like in [1], but ...
> Actually, I suppose I should clarify what I want to get at here, which is
> when lexical pads popped off the stack. Am I responsible for cleaning up
> any lexical pads I push on the stack? (I assume I am, but just wanted to
> be sure) ie) If I'm in a subroutine that just pushed a lexical pad on the
> stack and an exception gets thrown, do I have to catch the exception, pop
> the pad off the stack, and then rethrow the exception?
... you don't need to. The lexical pads hangs off the context structure.
Whenever the context changes, either by returning from a Sub call or
when an exception was thrown, the context is restored to the previous
state, and the lexicals with their pads are gone.
> Cory
leo
[1]
$ cat lex.imc
.sub main @MAIN
new_pad 0
new_pad -1
$P0 = peek_pad
$I0 = elements $P0
print $I0
new_pad -1
$P0 = peek_pad
$I0 = elements $P0
print $I0
print "\n"
.end
$ ./parrot lex.imc
23