yes I see this funny usage :) but I rather have both behaviours (compile+runtime) merged somehow...
looks like this only makes sense if
my $var = expr;
is allowed, and
my $var = expr if/unless cond;
forbidden... or replaced with `?:'
my $var = cond ? expr : undef
or even
my $var = cond ? expr; # invalid
:)))
anyway I got this shade of gray, thanx. :)
On Tue, 01 Jul 2003 10:40:26 -0400
"Bernie Cosell" <[EMAIL PROTECTED]> wrote:
> On 1 Jul 2003 at 17:15, Vladi Belperchinov-Shabanski wrote:
>
> > this one:
> >
> > use strict;
> >
> > for(1..3)
> > {
> > my $id = 1 if $_ == 3;
> > print "[$id]\n";
> > $id = 999;
> > }
>
> This is just another instance of what I've posted about [on c.l.p.m] a
> few times, "cheap static variables". Perl's mechanism for static
> variables is very elegant and very powerful, but is pretty syntactically
> ugly and generally is more than you want. So if you just do:
>
> sub x
> { my $staticvbl if 0 ;
> ....
> }
>
> You now have a simple static variable -- the 'my' gets compiled at
> compile time, so you get a variable and 'use strict' is happy... BUT:
> since the 'my' isn't *executed* at run time, you end up with the effect
> of a static variable.
>
> For example:
> sub x
> { my $staticvbl if 0 ;
> $staticvbl += 1 ;
> print "$staticvbl\n" ;
> }
> x();
> x();
> x();
>
> prints:
> 1
> 2
> 3
>
> /Bernie\
>
> --
> Bernie Cosell Fantasy Farm Fibers
> mailto:[EMAIL PROTECTED] Pearisburg, VA
> --> Too many people, too few sheep <--
>
>
>
>
--
*** WARNING: PLEASE DO NOT WRITE ME AT [EMAIL PROTECTED] ***
MAIL.BG SERVICE IS BROKEN AND DROPS OR REFUSES MESSAGES
--
Vladi Belperchinov-Shabanski <[EMAIL PROTECTED]> <[EMAIL PROTECTED]>
Personal home page at http://soul.datamax.bg/~cade
DataMax SA http://www.datamax.bg
Welcome to this crazy world, welcome to the show that never ends...
pgp00000.pgp
Description: PGP signature
