[Dev-luatex] Strange behaviour

Hans Hagen pragma at wxs.nl
Sun Feb 1 23:59:29 CET 2009


Elie Roux wrote:

> The other behaviour I find strange is that an attribute on a node can be 
> both 1 and -1... It's just a curiosity, as the good way to test if an 
> attribute exists is (I think) to call node.has_attribute with only two 

setting an attribute to -1 is equivalent unsetting it (so the 
has_attribute test then returns nil); however the attribute node is 
still there since it's more efficient to release it when the node itself 
is released; we experimented with different implementations (sets, etc) 
but the current was the most efficient

we might use other negative values for special purposes (at least that 
was the original idea) so don't make code that depends on negative 
values because at some point we might make use of them

 > arguments. Also, is there a way to get the value of an attribute on a
 > node by doing something else than testing some?

you could follow the linked list of attributes of a node but in general 
the test

local a = node.has_attributes(n,123)

if a then
   ...
end

is more efficient

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