From: Hans Hagen <j.hagen@xs4all.nl>
To: Neven Sajko <nsajko@gmail.com>
Cc: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Snooping around in LMTX: Questions about Lua global variables
Date: Tue, 22 Dec 2020 20:15:30 +0100 [thread overview]
Message-ID: <533939bf-1d6b-a69b-25ec-2ca40099e0e4@xs4all.nl> (raw)
In-Reply-To: <CAL+bK4PqLgFK8Fap=4i4=vsdZbVYyonpTRpm_hbTc=c-oQG7cQ@mail.gmail.com>
On 12/22/2020 7:32 PM, Neven Sajko wrote:
> On Tue, 22 Dec 2020 at 18:15, Hans Hagen <j.hagen@xs4all.nl> 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
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
next prev parent reply other threads:[~2020-12-22 19:15 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-22 17:36 Neven Sajko
2020-12-22 17:57 ` Neven Sajko
2020-12-22 18:15 ` Hans Hagen
2020-12-22 18:32 ` Neven Sajko
2020-12-22 19:15 ` Hans Hagen [this message]
2020-12-22 18:06 ` Hans Hagen
2020-12-22 18:13 ` Neven Sajko
2020-12-22 18:23 ` Hans Hagen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=533939bf-1d6b-a69b-25ec-2ca40099e0e4@xs4all.nl \
--to=j.hagen@xs4all.nl \
--cc=nsajko@gmail.com \
--cc=ntg-context@ntg.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).