[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: __pairs metamethod - is it in?
- From: "Steve Donovan" <sjdonova@...>
- Date: Mon, 07 Feb 2005 14:24:47 +0200
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.
>
>
>