[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Automating local optimization (Re: Is "scripting" truly Lua's future?)
- From: Asko Kauppi <askok@...>
- Date: Tue, 16 Sep 2008 09:31:49 +0300
Actually, a syntax modifier could easily automatically make all your
"usual globals" declared as locals.
It could even change references to string.* etc. to be locals.
Without you needing to do this explicitly.
print( string.find )
local print= print -- prefix code automatically added to each chunk
local string= string
local string_find= string.find
print( string_find ) -- modified of the actual source above
Would you rather have it this way?
David Given kirjoitti 15.9.2008 kello 19:04:
Tony Finch wrote:
On Fri, 12 Sep 2008, David Given wrote:
- Lua doesn't have a preprocessor. My app was made up of multiple
files, and most of the time I wanted the same common header at the
of each source file (importing C functions, mostly). Many's the
wished for #include.
It's a dynamic language, so you achieve something like that by
global function which sets up the namespace at run time.
Yes, except that these are all local variables, which means they're
lexical and don't exist in a namespace.
All my Lua files tend to start with the same boilerplate containing
local string_find = string.find
local table_insert = table.insert
local print = print
...etc. It would be really nice to be able to common this somehow.