lua-users home
lua-l archive

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


On Monday 21 June 2004 09:25, Philippe Lhoste wrote:
> Vijay Aswadhati wrote:
> > I have seen "use the proxy table" answers on one too many occasions.
>
> [snip]
>
> > So the question is this: is it worth requesting this as a feature in
> > 5.1?
>
> Probably yes (IMHO) but I suppose there are issues with that, otherwise
> it would have been a feature of Lua since a long time.

The issue is most likely one of speed. The current behaviour is invoked only 
for 'tables misses', which are presumed rare. The behaviour you are 
suggesting would require an additional lookup for every table access, 
regardless of whether the table actually has this metamethod. The same 
problem applies for a __next metamethod, which is one I'd certainly find 
useful.

The solution, I believe, is to support the __next metamethod for userdatas 
only, and then add a 'proxy userdata' constructor to the standard library. 
That would allow fully transparent proxies with reasonable efficiency, and 
obviously they would then be in the reference manual.

Of course, I should mention that proxy tables are included in Roberto's book.

-- Jamie Webb