lua-users home
lua-l archive

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


> 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
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.
--lhf