lua-users home
lua-l archive

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

Thanks for the pointers to strict.lua.  I'm working on integrating that
at the moment.   I'm just working through a few hiccups whereby strict
lua causes lua_getglobal to barf on missing globals, rather than
returning nil (I guess I can't have my cake and eat it) :)  

I'm not sure how it will interfere with my sandboxes either...

> -----Original Message-----
> From: 
> [] On Behalf Of Thomas Lauer
> Sent: 17 September 2007 11:22
> To: Lua list
> Subject: Re: Explicit declaration of variables
> "Tom Miles" <> wrote:
> > I'm not going to ask why variables don't need to explicitly 
> declared 
> > as I have learnt my lesson from my last post, but having spent yet 
> > another hour or so tracking down a bug due to a typo causing a 
> > variable to be automotically created and assigned a nil value,
> Well, if it helps you... that was my first stumbling block as 
> well and it's still my #1 gripe about Lua.
> I have since tried various avenues to have the compiler 
> complain about undeclared globals but it turned out that this 
> is a knottier problem than it appears. A fully-fledged 
> compile-time implementation (as opposed to runtime checks, 
> see below) is not trivial. At the very least it would 
> significantly complicate the compiler implementation (which 
> is currently a model of clarity and efficiency). I decided 
> that the benefits wouldn't outweigh the effort.
> > I was wondering if
> > anyone had written a patch to stop this behaviour?
> Not a patch as such but there's a file in the Lua distribution (see
> etc/strict.lua) that somewhat alleviates the situation by 
> doing runtime checks. This works well and it's not as 
> inefficient as it sounds. (FWIW, I've done a module on the 
> basis of this that supports modules as well, see 
> .)
> --
> cheers  thomasl
> web :

This email is sent by The Creative Assembly Limited company No. 03425917, registered in England &Wales registered office 27 Great West Road, Middlesex, TW8 9BW, England. The contents of this e-mail and any attachments are confidential to the intended recipient and may also be legally privileged. Unless you are the named addressee (or authorised to receive for the addressee) of this email you may not copy, disclose or distribute it to anyone else. If you have received this email in error, please notify us immediately by e-mail on and then delete the email and any copies. The Creative Assembly Limited have made all reasonable efforts to ensure that this e-mail and any attached documents or software are free from software viruses, but it is the recipient's responsibility to confirm this.