lua-users home
lua-l archive

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


I don't have clear answers for this. You are correct that this would have
implications for t[ x ] if carried through to its logical conclusion.

But I find it odd to allow length to get redefined for tables and not for
strings and there seemed to be a strong consensus for not redefining it for
strings. So, I was looking for a way to make it consistent.

The OP_SELF stuff had to do with making sure that one could send messages to
basic types in some way.

Mark

on 8/3/05 3:53 PM, Rici Lake at lua@ricilake.net wrote:

> 
> On 3-Aug-05, at 5:22 PM, Mark Hamburg wrote:
> 
>> Not that anyone probably wants to change 5.1 at this point, but maybe
>> the
>> answer to these issues is a way to override OP_SELF to better work with
>> basic types. That way, one could define default implementations for
>> things
>> like:
>> 
>>     t:insert
>>     s:len
>>     t:len
> 
> That seems counter to the behaviour of metamethods on other operators.
> Or would you also suggest that a[x] be changed to rawget(a, x) and
> metauses rewritten as a:get(x)? And, by the same token, a:plus(b) to
> get the metamethodical '+'? I think the syntactic beauty of metamethods
> is precisely that they are easy to write.
> 
> It's not clear to me how OP_SELF could work with the table basic type,
> in any event, unless it were redefined to only look in the metatable.
> Otherwise, it would limit the keys you could place in a table (viz.
> javascript irritations).
> 
> R
>