On 12/22/2020 7:32 PM, Neven Sajko wrote:
On Tue, 22 Dec 2020 at 18:15, Hans Hagen
wrote: On 12/22/2020 6:57 PM, Neven Sajko wrote:
Oops, I forgot to attach the scriptlet before.
[...] I guess it could also be more performant, because Lua would conceivably spend less time managing huge tables.
Now that I think about this some more, it doesn't actually make sense. However I'm still interested in whether it is really necessary to have that many globals exposed. most of what you see in that generated file is either unicode data or font resources ... all needed (and geared for performance)
OK, now that I think just about the real global variables (instead of the "recursive" globals): would it make sense to transfer all the non-Lua-default globals into two tables, one for Lua(Meta)Tex, and another table for ConTeXt, so those would be the only two additional global variables?
well, and then if you load some library that would add some global again ... so it's a chicken egg problem.
I'm not proposing you do it, since it seems like it could be a lot of work, I'm just wondering what you think about that, because it seems like things would be much tidier like that (less chance of accidentally accessing a global in Lua code, etc.). You can create your own instance:
\definenamedlua[mylua] \startmyluacode global.context("USER 1") context.par() context("USER 2") context.par() if characters then context("ACCESS directly") elseif global.characters then context("ACCESS via global") else context("NO ACCESS at all") end context.par() if bogus then context("ACCESS directly") elseif global.bogus then context("ACCESS via global") else context("NO ACCESS at all") end context.par() \stopmyluacode I admit that I never run into conflicts. Ok, I never load libraries, mostly because we havne plenty of helpers on board. Changing the approach now would invalidate a lot of user code (and also mean a lot of work plus probably make us run into the > 200 locals issue due to aliasing). Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------