lua-users home
lua-l archive

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

On Saturday 24 September 2005 01:05, Eric Jacobs wrote:
> I have a situation similar to this. I've grown fond of the following
> technique to call object methods. I think it's a big win once you get used
> to its syntax:
>         obj[intf.method]()

I quite like this --- it's elegant. Unfortunately, I doubt my users will 
agree... I suspect they'd prefer traditional syntax.

I think what I'll do is to have a table that represents each interface, 
containing bindings for the methods, created lazily, and then have a C 
dispatcher on the object that tries each interface in turn. I think in this 
case the reduced complexity outweighs the performance improvements in trying 
to do anything more complex; plus, with appropriate metatable abuse I can do 
the hard work in generating the bindings from Lua, which would be nice.

Thanks, everyone!

+- David Given --McQ-+ "The first 90% of the code takes the first 90% of
|    | the time. The other 10% takes the other 90% of the
| ( | time." --- Anonymous
+- --+ 

Attachment: pgpOHmYTWAEJH.pgp
Description: PGP signature