Re: Possible language extension: colon-notation in an expression as shorthand for instance-specific method
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Possible language extension: colon-notation in an expression as shorthand for instance-specific method
- From: Dolphin <dhawkins@...>
- Date: 2009年1月27日 17:36:46 +0000 (UTC)
> CallbackManager.postMyCallback(wrap(myInstance).instanceMethod)
>
> where:
>
> function wrap(instance)
> return setmetatable({}, {__index=function(_, method)
> return function(...)
> return instance[method])(instance, ...)
> end
> end})
> end
>
> This could be a good starting point to implement the colon syntax
> extension proposal with a simple token filter.
Coming from a constrained memory environment, that is really scary as you are
creating two tables, a closure and a vararg function, a lot of overhead IMO. I
do love however, that lua provides the functionality to do things like this, I
just wish you could do it cheaper.