lua-users home
lua-l archive

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


On Fri, Dec 08, 2000 at 02:04:39PM -0800, Falko Poiker wrote:
> Interesting idea.  Did you use the getglobal(NIL) tagmethod for this?

Yes.

> The difference in our game is that we're planning on exposingthe lua 
> layer to mod groups so they can modify ai, as well as other scripted 
> variables and functions.  Of course we could let those people run the 
> game in "developer mode" that turns on the case/spelling check (with 
> the accompanying performance hit).

Yeah, that's a good way to do it.

> There is also the aformentioned problem of local variables.  If 
> globals are checked and locals are not, it could discourage designers 
> from using local variables...

We didn't worry so much about locals because you're usually looking right
at whatever the problem is.  However, exactly recalling the way the
variable was named as a global or table element elsewhere is kind of a pain
in the butt, and that's the problem this attacks.  There's also the problem
in a large body of code because you have a bunch of unclear
dependencies... If someone changes the name or remvoes the variable
elsewhere, you don't get an undefined reference telling you what's wrong as
you would with C.  =)  With the indirection in place, things break
visibly when the variable is no longer explicitly declared, whereas you
might get reasonable behavior sometimes based on a nil value otherwise.

> > We started using that at the beginning of Monkey... Not only did 
> > it catch lots of mistakes, but it encouraged people to document 
> > what variables did at the opint where they "declared" them.
> How exactly does this system encourage documentation?  I think it's 
> a great idea, but it's not obvious to me how this works.

People tend to get organized and stick all of their variable "declarations"
at the top of a file.  At the point where you're doing that, it's pretty
easy to comment what it does or why you need it.  Otherwise people just
start using a variable name and there's no explanation but context.  I
guess it doesn't enforce it, but having all of your variables named in one
place does let you see things more clearly.


Bret
-- 
Bret Mogilefsky  ** mogul@gelatinous.com **  Programmer, SCEA R&D