On Fri, Jan 14, 2005 at 02:46:58PM -0500, Austin Hastings wrote:
> >rules, I can easily have it either way.  
> >
> >      {for (my $n=0; $n<10; ++$n) {...}}   # Local to loop
> >       for (my $n=0; $n<10; ++$n) {...}    # Persistent
> >
> >--Dks
> >
> But there's no clean way to make some of them temporary and some 
> persistent.
> 
> This seems like a legitimate place for "saying what you intend", viz:
> 
> for (my $n is longlasting = 0, $m = 1; ...) {...}


I see your point, but:

- at least in the kinds of programming I do, I rarely use more than
  one loop variable  (with the exception of nested loops, and even
  there the second var is declared in the second loop line)

- even when I do, only rarely do I want some of them to persist and
  some not

- if I do, I'm willing to suffer the minor ugliness of putting the
  to-be-persistent ones outside the scope, rather than have to use a
  property every time I want ANYTHING persistent.  

- I would much prefer this:

       my ($total, $last_seen, $had_errors) = (0)x3;
       for ($my $i=0; $i < @elements; $i++) {...}

  To this:

       for (my $i=0, 
               $total=0 is longlasting,
               $last_seen=0 is longlasting, 
               $had_errors=0 is longlasting; 
            $i < @elements;
            $i++) 
       {
        ...
       }


FWIW....

--Dks

Reply via email to