develooper Front page | perl.fwp | Postings from July 2003

Re: my if?

From:
sthoenna
Date:
July 1, 2003 21:52
Subject:
Re: my if?
Message ID:
XAlA/gzkgWkM092yn@efn.org
On Tue, 1 Jul 2003 10:30:34 -0400, rjk@linguist.Thayer.dartmouth.edu wrote:
>On Tue, Jul 01, 2003 at 05:15:09PM +0300, Vladi Belperchinov-Shabanski wrote:
>>   my $id = 1 if $_ == 3;
>This was an accidental feature that is now kept for backwards
>compatibility, because some programmers have used it to create static
>variables.  It's best to avoid it, however.

As others have observed, it doesn't really make static variables since
a new pad will be used for each level of recursion.  I also think that
with multiple ithreads, each thread will use a different pad.

I don't think it was kept for backwards compatibility; I think it just
would be very difficult to make it work otherwise, though Dave
Mitchell and Gurusamy Sarathy have discussed[1] doing so (with,
surprisingly, no objections).  The problem with keeping it is that
people keep stumbling across it accidentally.

[1] http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2003-03/msg00019.html



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About