[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: help to (slightly) modify Lua interpreter
- From: David Manura <dm.lua@...>
- Date: Fri, 6 Nov 2009 19:20:05 -0500
On Thu, Nov 5, 2009 at 1:59 PM, Doug Rogers wrote:
> Well, you've inspired me to do some crazy coding. I use the __call
> metamethod on a tensor (matrix of possibly more dimensions) to return an
> element-reference object whose own __call metamethod allows access to
> the element. I also provide set() and get() functions may be used for
> the element-reference object. Finally, just for fun, I overload __index
> and __newindex to get or set the element, but that requires a dummy index
> ...
> local _ = true -- Can be anything except nil.
> p(1,2,3)[_] = 123
> print(p(1,2,3)[_])
This variant would be preferable:
p(1,2,3).v = 123
print(p(1,2,3).v)
Something like that is actually done when scripting Excel:
ws.Cells(1, 2).Value = y