[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: In praise of globals
- From: Thomas Jericke <tjericke@...>
- Date: Wed, 17 Apr 2013 07:20:26 +0200
That's pretty much what strict Lua does, and we do something similar as
strict Lua (my version also lets you define constants).
But it's not what I wanted to suggest.
What I suggest is a change of the language. This means the parser would
not allow LHS globals. You would catch this kind of error already at
compile time, not at runtime. Errors at compile time are much, much
better than provoking an error in the middle of a process. Our Lua
scripts run real machines, it is really important that they run through.
You can do this already.
Lua 5.2.2 Copyright (C) 1994-2013 Lua.org, PUC-Rio
function assign(key,value) rawset(_G,key,value) end
function() error"Global LHS values are banned." end})
stdin:2: Global LHS values are banned.
[C]: in function 'error'
stdin:2: in function '__newindex'
stdin:1: in main chunk
[C]: in ?