ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Neven Sajko <nsajko@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Snooping around in LMTX: Questions about Lua global variables
Date: Tue, 22 Dec 2020 17:36:51 +0000	[thread overview]
Message-ID: <CAL+bK4OGQD52aTPZ_hgHAvHmeuV6PKLMZFOY_srqxWLd2MyNgA@mail.gmail.com> (raw)

Hello again,

While learning about how to drive TeX through Lua, I decided to
recursively list all Lua global variables (actually this is traversing
the _G table) in the LMTX environment, half to learn more Lua, half
for getting to know ConTeXt better.

I was quite surprised by the huge size of the environment, a file that
contains the listing of all the globals is 42 MB long! I wonder if it
would be possible to reduce the exposed globals by replacing some of
them by getter and setter-like functions? That seems like it would be
much nicer and less error prone - because Lua is so dynamic, polluting
the global namespace seems even more dangerous than in C-like
languages. I guess it could also be more performant, because Lua would
conceivably spend less time managing huge tables.

There were also some global variables with suspicious random variation
in values between runs of ConTeXt: I ran my Lua script like so
multiple times (attached, in case someone is interested in it):

    context s.lua
    rm s.tuc s.pdf s.log

And I found that the values of some variables unpredictably and randomly vary:

The variable resolvers.suffixmap.lua sometimes has the value
"scripts", and sometimes "lua". I think this means that files with the
file name suffix ".lua" are sometimes classified as general scripts
and sometimes as Lua scripts. This seems like it could even be a bug?

The variables storage.tofmodules and storage.toftables are also
interesting: they vary from run to run like this:

tofmodules: 0.175483 0.149536 0.150493 0.150005

toftables: 0.008407 0.008118 0.008395 0.008116

I'd like to know what is their purpose, if it's not to involved to explain?

Thanks,
Neven
___________________________________________________________________________________
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
___________________________________________________________________________________

             reply	other threads:[~2020-12-22 17:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-22 17:36 Neven Sajko [this message]
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
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=CAL+bK4OGQD52aTPZ_hgHAvHmeuV6PKLMZFOY_srqxWLd2MyNgA@mail.gmail.com \
    --to=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).