Am 2019-01-09 um 20:57 schrieb Thomas A. Schmitz
I've finished testing my lua script, and it does exactly what I need. I think I'll write a small article about it for one of the next context group proceedings,
Hi Thomas, since I’m just starting to work on the current CG journal (sorry, life happens...), I might fit your article in. And a German version would be welcome for DANTE’s DTK.
3. Lua's handling of tables is very efficient and fast. For analyzing my Greek texts, I have to use huge tables for morphological parsing, with more than 900,000 entries. Looking up words in these tables is around 3x faster in Lua than in python!
Nice to know. Maybe I should try to convert some of my Python code (esp. the ConTeXt related scripts)...
One final thought: one limitation that I still find cumbersome to work around is the fact that associative arrays ("pairs" in Lua speak) do not have an order. When I analyze my texts, I want book numbers, chapters, paragraphs preserved in the order in which they are read (entered into the table). In many cases, it is not possible (or extremely awkward) to sort these numbers, since chapters may be numbered something like 2, 2a, 3, 3α, 3β etc. python has the OrderedDict() in its collections module. In Lua, the best I could find was entering the chapter numbers into an array (ipair) and then retrieve it from there. Maybe there is a better way?
Since Python’s usual dict is also unordered, I guess OrderedDict also just uses an index array under the hood. Python makes it easy to create new classes (also data types) that behave like something known. Don’t know how that would look in Lua... Python’s batteries are much bigger than Lua(TeX)’s. Of course Lua should be kept small, but there are always things missing. My Lua library for invoices with ConTeXt e.g. uses an object model from an obscure Lua library. Probably it would make more sense to use Lua’s tables in a native way than to insist on objects. I also missed a good GUI library (with widgets); I chose tekui and added some GUI-from-configuration stuff, but got stuck, since I’m comfortable with my CLI scripts anyway... Greetlings, Hraban --- https://www.fiee.net http://wiki.contextgarden.net https://www.dreiviertelhaus.de GPG Key ID 1C9B22FD