[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: string.gsub accepting a callable userdata
- From: Wesley Smith <wesley.hoke@...>
- Date: Wed, 12 Dec 2012 23:47:12 -0800
> string.gsub is one of the most powerful Lua functions we have, and the
> substitution may be a string, a table, or a function.
>
> It would be useful if this list could be extended to include callable
> userdata - in most language interop situations I've encountered,
> foreign functions are represented in this way on the Lua side.
>
> (It would be too confusing to allow callable _tables_ of course)
>
Couldn't you just use a table as a proxy for userdata via __index?
It's not ideal to have to proxy, but you could easily make a wrapper
function so that you can pretend it's not happening :)