|
On 11.04.2014 04:59, Hisham wrote:
An alternative would be to do things the other way around: use __call as the accessor and a tracker:add() function to add data. Might be a good idea if you read data more often than you write it. tracker = my_fancy_tracker(3) -- three tracks... tracker:add(1, 2, 3) tracker:add(7, 8, 9) local a, b, c = tracker(-1) -- setting a,b,c=7,8,9 and local e, f, g = tracker(1) -- setting e,f,g=1,2,3
Yes, and by checking the arguments of __call you can even get away with only __call for both directions. But this quickly becomes ambiguous. I've settled for the :at().