On Tue, Sep 26, 2006 at 12:27:21PM +0100, David Cantrell wrote:
> On Mon, Sep 25, 2006 at 11:22:46PM -0400, John Macdonald wrote:
> > On Mon, Sep 25, 2006 at 12:35:49PM +0100, David Cantrell wrote:
> > > On Thu, Sep 21, 2006 at 07:02:56PM -0400, Duane Bronson top-posted:
> > > > Ronald J Kimball wrote:
> > > > > What would you have Perl do in the case of nested loops?
> > > > $.. should be the iterator count in the parent loop, $... should be the 
> > > > iterator count in the grandparent loop, ...
> > > Ick!  Better to use a stack, methinks, like I do for getting at outer
> > > map{}s' versions of $_ in NestedMap.
> > And even using a stack suffers from the flaw that any sort
> > of refactoring that puts a loop around a portion of the code
> > means search through the entire section and increasing the
> > index of any reference to a loop outside the new one ...
> 
> Any refactoring should be done carefully and with understanding of what
> the code you're refactoring is doing.  I'm not sure what your point is.

Wrapping a loop around a large chunk of code would change
the meaning of some of the variables within the chunk.
(The most likely candidate would be turning a single loop
into a nested pair of loops.  Instead of the code inside
the loop just working and only needing an extra indent, that
code would have to be scanned for all loop index references
and each one counted to see whether it is inside or outside
the change and adjusted accordingly.  If, instead of relative
names, the index for loops that needed index counters had been
given explicit names, the names would still refer to the same
loop index after the change and just continue to work correctly
without any examination and fixing required.  There's also the
potential for confusion about whether map, grep, and postfix
for get index counters (and what if the interpreter wanted to
just code one of them as an internal re-write that *did* use a
loop; and then the implementation changed).
)

-- 
 
_______________________________________________
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to