develooper Front page | perl.perl5.porters | Postings from March 2003

Re: PROPOSAL: my $x if $false; and lexical initialisation

Thread Previous | Thread Next
From:
Gurusamy Sarathy
Date:
March 2, 2003 11:25
Subject:
Re: PROPOSAL: my $x if $false; and lexical initialisation
Message ID:
200303021924.h22JOiB29421@smtp3.ActiveState.com
On Sun, 02 Mar 2003 13:13:15 GMT, Dave Mitchell wrote:
>On Sat, Mar 01, 2003 at 04:29:26PM -0800, Gurusamy Sarathy wrote:
>> >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);
>
>
>Don't both these two approaches have roughly the same effect - ie they are
>both migrating the 'intro' actions to the start of the statement
>containing the my?

Yes, the effect should be the same.

>Although presumably your approapch involves
>maipulating the parser while mine involves the peephole optimiser?

Changing the grammar should not be necessary.  However in the
first case you get to manipulate these OPs as you parse the code
whereas doing it in peep() means that you'll need to put it off
until the end.  If the implementation turns out to be easier/cleaner,
you may want to go for doing it in peep().


Sarathy
gsar@ActiveState.com

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