[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Suggestion for 5.3: import() for creating a "slew" of locals
- From: Philipp Janda <siffiejoe@...>
- Date: Tue, 19 Nov 2013 02:22:10 +0100
Am 19.11.2013 00:00 schröbte Sir Pogsalot:
As far as I know, assigning to the allocated locals would involve a table
lookup *once* at runtime -- the local access would still be faster? Maybe
I'm wrong? :>
The assignment is not the problem. *Using* the dynamic locals is: You
would need to change the way locals are implemented (or patch the
bytecode at runtime).
Now:
local tconcat = table.concat -- use register no. 4 for tconcat
-- ...
-- tconcat is register no. 4, so do a getlocal(4) or getupval(4):
print( tconcat( sometable ) )
Then:
import( table, { "concat" }, "t" )
-- ...
-- need to change the getglobal("tconcat")/getlocal(x)/getupval(x)
-- to a getlocal(y) or getupval(y) when import is finished:
print( tconcat( t ) )
An alternative would be an `import` compiler directive, so that register
allocation happens at compile time again. You would need a different
syntax though, because `{ "concat" }` can't be a table constructor
anymore (and "t" a string), because you need the list and prefix at
compile time. And now we are back to macros/token filters ...
Philipp