lua-users home
lua-l archive

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


Miles Bader <miles.bader@necel.com> wrote:

> Thomas Lauer <thomas.lauer@virgin.net> writes:
> > It seems either a separate lint and/or those runtime checks are the
> > way to go.
> 
> It'd be nice if the runtime checks were as cheap as possible though --
> e.g., _G actually contains the global values and doesn't incur an
> __index call for every lookup!

__index isn't called for *every* lookup. It's only called if the field
that's referred to doesn't yet exist. Most accesses into _G are not
touched by the strict module.

But if you know of ways to make this more efficient I'd love to hear
about them.

> Looking at the example "strict" module, it calls "debug" module stuff,
> which seems a little bit dodgy to me (I generally have the idea that
> the debug module shouldn't be used when not debugging...).

In theory I agree. In practice there seems to be no other documented way
to get the information where a variable "is coming from".

I agree with the general sentiment that this way of doing checks is sort
of a hack, that's exactly why I was looking for something cleaner.

-- 
cheers  thomasl

web : http://thomaslauer.com/start