[Dev-luatex] Assignments in Lua

Taco Hoekwater taco at elvenkind.com
Wed May 21 13:20:52 CEST 2008

Jonathan Sauer wrote:
> Now, a few months and betas ago, assignments made inside Lua to
> tex.count et cetera were always global (see my posting on August 14th
> 2007 on this mailing list).

Actually that behaviour was a bug, not intended, not consistent.
I changed it a little while after your posting so that is now
obeys grouping. The rationale for picking grouped instead of
global was that you could temporarily set tex.globaldefs=1 if you
really needed global (note: that does not actually work either)

The issue I had was trying to find a nice solution for

    tex.count[0] = 5

Now I just realized (this morning) that I could create a second
virtual array named

    tex.globalcount[0] = 5

or some such. Your

    tex.setcount (0,5,true)

proposal is fine, but the array access is so neat that I would like
to keep it.

> I would try my hand at a patch to implement this, but unfortunately, I
> cannot find the function prototype for set_tex_count_register. A

It is in luatex.web, just below get_tex_count_register.

> sketch:
> -	Modify <set_tex_count_register> et.al. so that 'a' is no longer 
> 	a constant local variable, but a parameter.

> -	In ltexlib.c, check for an optional boolean using <lua_toboolean>,
> 	then pass either zero (local/false) or four (global/true) as the
> 	third parameter to <set_tex_count_register> et.al.

> -	Add a call to @<Adjust \(f)for the setting of \.{\\globaldefs}@>
> 	in <set_tex_count_register> et.al. so that \globaldefs works
> 	correctly.

Sounds fine.

> I'm not sure about the last point, though, since it would mean that
> TeX would influence Lua's behaviour.

It was supposed to, I simply forgot.

Your web implementation proposal sounds fine, but before we do anything
about extending the lua syntax, we have to think about those array 
accesses and the other tex internals, I think.

The interface to the tex internals is still incomplete, and that
is mostly because of syntax issues. It is fun that we can write

   tex.globalsdefs = 1

as an assignment instead of as a function call, and

   tex.count[0] = 5

as well, but many internal parameters are not interfaced yet because
they are not so simple. The tricky bit is that I fear that some of the
internals really require a functioncall instead of assignment,  for 
example \parshape and \fontdimen.

> Another thing: Setting an attribute using tex.attribute does not seem
> to add the attribute to nodes, contrary to setting it in TeX. Most
> ...
> And while we're at it: In luatex.wb line 27777,
> 	help1("I'll pretend you didn't say \long or \outer or \global.");

Thanks, I will apply thse right away.

Best wishes,

More information about the dev-luatex mailing list