[Dev-luatex] Assignments in TeX's mouth, or: "Dr. Zaius, it can talk!"

Hans Hagen pragma at wxs.nl
Tue Aug 14 12:55:54 CEST 2007


Jonathan Sauer wrote:

> BTW: Why is it possible to have 268435456 (2^28) catcode tables?
> That strikes me, more than 65536 registers, as nearly unlimited.
> Why not "only" 65536, especially since one would likely run out
> of memory long before exhausting this amount?

the same is true for the number of lua instances, one seldom needs more 
than a few, but we saw no reason for a limitation

>>> So, returning to this mail's subject, I can only say: "Take 
>>> your hands off my grouping, you damn dirty Lua code!" ;-)
>> well, don't use tex.count then -)  often the same can be 
>> accomplished by:
>>
>>     tex.sprint("\\count123=",value)
> 
> But this is not expandable. Also, the assignment will be executed
> after the LuaTeX code, so other Lua code cannot use the register
> (it will use the old value). This creates a new kind of
> asynchronous execution, similar to TeX's mouth and stomach, only
> this time between Lua and TeX.
> 
>> which will honor grouping, or a variant of this
>>
>>     \count123=\directlua0{... tex.sprint(value) }
>>
>> introducing a grouping model in lua itself is messy; one has 
>> to live with the fact that both languages hav edifferent 
>> models; actually, once there is mplib, there is yet another 
>> grouping model -)
> 
> Why exactly is it messy? I would assume -- without having looked
> into the source -- that to set a register, a procedure is called
> with the register type (count, skip ...), the register number, the
> new value and a flag if the assignment should be global. This
> procedure then takes care of handling the grouping. Why cannot
> this procedure be called from Lua code (or the tex library, to be
> precise) as well?

if i remember right, it was not as easy as that (is true for more tex 
internals); maybe in the long run a more sophisticated grouping model 
will surface, for instance we've been discussing assignments to 
registers that migrate after the the current group (handy for local 
calculations where the result has to be caried over) but this has a low 
priority (fonts, list manipulations has the highest)

> To leave the technical standpoint: When writing Lua code, the
> programmer uses Lua's scoping model. When accessing TeX's
> registers from Lua code, he/she/it uses TeX's grouping model,
> since they are part of TeX, not part of the Lua language. I do
> not think this is particularly messy.
> 
> Still, if assignments using tex.count et.al. stay global, this
> should, IMO, be stated in the manual.

sure, i agree with that; and we can also add that it is currently a 
limitation that may be removed in future releases -)

btw, a similar tricky area is in box manipulations, where one can 
construct node list and assign it to a box ...

tex.box[0] = head_of_my_new_list

if box[0] has content already, one has to make sure that this is freed 
properly, otherwise memory will remain allocated; so, for all interfaces 
certain 'rules of usage' apply.

keep in mind that luatex is a multi-year project -)

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
      tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------


More information about the dev-luatex mailing list