On Sat, 01 Mar 2003 19:42:04 GMT, Dave Mitchell wrote: >On Sat, Mar 01, 2003 at 11:19:52AM -0800, Gurusamy Sarathy wrote: >> I'm not sure nextstate is the best place for this. Since this is >> only needed once per scope, checking for it once-per-statement >> seems like wasted cycles. >> >> Why not do it in the OP_LEAVE* ops? Or perhaps even introduce >> a new OP_LEAVEMY that only fires if there are lexicals that >> need to be finalized in that scope. > >Hmmm.... > >A problem with an OP_LEAVEMY is that it often won't get called, eg Good point. Might make more sense to make the OP_ENTER* ops push savestack entries in block_end(). >Is there a way of ensuring that the op is always called no matter how the >scope is unwound? Not that I know of. >Another option would be to insert an OP_STARTMY after each nextstate >that preceeeded a my declaration ??? Seems kludgey for the cases where there is no nextstate preceding the padsv. Another way to approach it is to separate out the OP_PAD?V ops and move them to execute at the beginning of the statement, sort of as a preamble. This means transforming: my ($x, $y) = ("xxx") if $z; into the approximate equivalent of: my ($x, $y), (($x, $y) = ("xxx") if $z); (except that $x and $y have already been resolved as lexicals when the succeeding ops are compiled). It also means that this: my $x if $bool; would transform to: my $x, ($x if $bool); and could be optimized into: my $x; Sarathy gsar@ActiveState.comThread Previous | Thread Next