lua-users home
lua-l archive

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


Dimiter malkia Stanev wrote:
> 	Anyway I'm not getting something right here, as my __index callback
> is not hit everytime, although I've installed it with setmetatable.

__index and __newindex are only called if the corresponding table
entry doesn't exist (i.e. is nil). As soon as a non-nil value
exists for a key, no metamethods are called on reads or writes.

May I suggest you (re)read "Programming in Lua". :-)

> 	And I'm trying to make lazy "loaded" symbols to have their "seats"
> preserved, if someone calls their name, but still allow for others.
> This is simply to wrap (hence wraplib name) symbols that might be
> coming out of the dynamic library, and locally defined lua ones.
> 
> 	I'm not entirely sure whether that's good idea at all, but wanted
> to try and see.

Well no, I don't think this is a good idea. First: I wouldn't
bother with lazy loading -- libcurl doesn't have that many
symbols. And second: I cannot see any reason why a user of a
library would behave that way and why you go to these lengths
trying to forbid this.

I mean, anyone can write math.sin = math.random -- yeah, that's a
bad idea, but so what? It's the user's problem, if they do such
nonsense.

--Mike