lua-users home
lua-l archive

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


Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> writes:

>> I'd suggest adding a "__typeof()" metamethod to Lua, similar to  
>> __tostring() but used by the 'type()' built-in function.
>> 
>> The reason?  It could be used with userdata, to provide more  
>> information of the entity than just "userdata" does. For example, it  
>> could provide "enum/SDL_INIT", telling that the entity is an  
>> enumaration of logical type SDL_INIT.
>> 
>> The main benefit would be better error messages, and better type-wise  
>> expandability of Lua in general.
>
> We've been there I think. This is a bad idea because it will
> break all

why will it break?! all existing programs know nothing about
such method, they don't implement it. so, nothing'll happen at all.

> programs that rely on type returning a fixed set of values. You could
> make type return 2 values, one raw and one cooked, but it seems to me
> that it is simpler to have a separate function, say mytype.

-- 
Yours sincerely, Eugeny.
Doctor Web, Ltd. http://www.drweb.com