lua-users home
lua-l archive

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

steve donovan wrote:
On Wed, Jun 10, 2009 at 12:02 PM, Olivier Hamel<> wrote:
It does this already, last time I checked (-3 secs ago) Are you
thinking of hex string literals?
Oops, yah. My mistake, sorry!

As operators? I think most of us would live with a set of 'blessed'
functions to do this.
That could work, I just think it'd be/feel more elegant/neater to make them ops, then perhaps we can meta-overload them as well... ?
The thing, we're used to the rule that multiple args only get expanded
at the end of a table ctor. Maybe an explicit 'explode' function, but
keeping the default behaviour? Changes like this can break lots of
That will not be an issue, Roberto has already publicly confirmed he will be break everyone's code anyways: "Lua 5.2 is allowed to make design changes that break full compatibility." :p

But I do get your point, but the problem is that such an explode function would also be under the restrictions as the original function unless it were hacked deep into Lua, something I doubt would be popular with Roberto + others (including me). Perhaps some sort of lexer marker instead?
OK, so like __setindex if the key is nil, but works even otherwise.
You can then override '=' for keys basically.  But there are tricks
you can use already to get this effect, e.g. the key is actually
called '_a' but use __setindex so that 'A.a = 2' updates _a, etc.
No, no, I mean, if it's NOT nil then the metamethod get's called, it would allow you to create enforced single-assignment lists for example, or prevent overriding of a meta-method in the metatable. To prevent a new method from being inserted into the host table would require a __setindex sort of scheme, though with __setindex you could check for the current value of the key to check if it were nil. So __setindex solves both aspects! :) (Correct me if I'm wrong, but __setindex doesn't sound like any vanilla meta-method I know of. Am I wrong?)

Olivier Hamel