lua-users home
lua-l archive

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


Absolutely - I just have a sentimental fondness
for that bit of syntactical sugar ;)

steve d.

>>> asko.kauppi@sci.fi 02/07/05 02:17PM >>>

but.. if the code says "for i,v in pairs(t) do" then the overloading 
would work already now?


7.2.2005 kello 13:44, Steve Donovan kirjoitti:

  asko.kauppi@sci.fi 02/07/05 12:32PM >>>
>
>> Why so complicated?
>>    pairs = function( t )
>>         local mt = getmetatable( t )
>>         return ( ( mt and mt.__pairs ) or raw_pairs )( t )
>>     end
>
> It would be very cool if 'for i,v in t do...'
> would use the global pairs() function;  that would
> (a) make quite explicit what the for-loop means
> if t isn't an iterator function and (b) make interesting
> overloading possible, such as above.
>
> steve d.
>
>
>