lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tuesday 28 December 2010 18:05:28 Mark Hamburg wrote:
> On Dec 28, 2010, at 2:31 PM, Steve Litt wrote:
> > On Tuesday 28 December 2010 16:15:39 Mark Hamburg wrote:
> >> On Dec 28, 2010, at 11:45 AM, Richard Hundt wrote:
> >>> Is there something inherently Bad about doing this?
> >>>
> >>> for k,v in next, t, #t > 0 and #t or nil do
> >>>  ...
> >>> end
> >>
> >> There is nothing in the contract for next that guarantees that it will
> >> work.
> >
> > Can somebody please explain how Mark's algorithm works? In the docs at
> > http://www.lua.org/manual/5.1/manual.html it lists the following syntax
> > for next():
> 
> Not mine. Richard Hundt's. I hardly want to be credited with something I
>  don't recommend.

Sorry Mark. I was so bamboozled by the syntax that my confusion spilled over 
into who wrote what.

Now that I understand the syntax (thanks Doug), I agree with you this is a 
risky way to do it, because there's no guarantee that the elements with 
integer subscripts (or whatever you call them) will come first.

SteveT


Steve Litt
Recession Relief Package
http://www.recession-relief.US
Twitter: http://www.twitter.com/stevelitt