[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Type Metatables for Table and Userdata - Powerpatch
- From: Andrew Starks <andrew.starks@...>
- Date: Thu, 6 Dec 2012 21:57:51 -0600
> Sven Olsen wrote:
>> Unfortunately, it ("for k,v in t do ..." syntax) simultaneously obscures the function of the code.
>
> I do not understand what you mean- could you elaborate on this?
>
> --Wolfgang
>
Your explanation that for iterates through a table with using pairs
makes clear the intent. The obfuscation is from not seeing the
iteration method.
The full explanation of how it works is long, "Use an iterator
function. If its a non-callable table, or a callable table and no
second argument, then use pairs on the table. " or __iter?
Something that u said was different than my understanding, which is
that pairs was a magic function, not implement-able within lua. I
believe that is true of "next", but pairs more-or-less just wraps
that. I don't think pairs is magic, am I wrong?
Doesn't the completely valid "for k, v in next, t do" sorta kinda do
what you want, except for the over ride aspect, which is already in
the language?
I feel like I'm arguing now. It's at least fun to think on this stuff.
-Andrew