develooper Front page | perl.perl5.porters | Postings from January 2001

Re: Multiple post(inc|dec)rement

Thread Previous | Thread Next
From:
Stephen McCamant
Date:
January 16, 2001 16:39
Subject:
Re: Multiple post(inc|dec)rement
Message ID:
14948.59270.620964.260551@soda.csua.berkeley.edu
>>>>> "GNat" == Nathan Torkington <gnat@frii.com> writes:

GNat> Johan Vromans writes:

JV> My point is that unlogical exceptions like @a = (++$i,++$i,++$i)
JV> are hard to explain, and make people turn away from Perl.

GNat> Could the optimizer spot multiple side-effects in an expression
GNat> and pessimize it accordingly?

If you mean a syntactic expression, then yes, I think that would be
possible. In general, though, side effects might be hidden in
subroutines, AUTOLOADed subroutines, evals, etc:

perl -e 'sub f {++$i}; print ++$i, f(), "\n"'

It doesn't seem obvious to me that there's an easy or foolproof way to 
do this, though, and a half-right solution would probably be worse
that a the current situation, at least as far as being predictable and 
explainable.

 -- Stephen McC

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