[NTG-context] lpdf.checkedkey has problem with false values

Michail Vidiassov master at iaas.msu.ru
Mon Sep 15 16:14:59 CEST 2014


Dear Developers and All,

lpdf.checkedkey routine from lpdf-ini.lua has problems with accessing
false boolean values, it returns them as nil. Is it by design or
neglect?
(I vaguely remember stumbling on this problems before, so  there is a
chance that I have already got the answer, but have forgotten it.)
The minimal demo:
\starttext
\startluacode
local function writebool(bv,text)
 if bv == true then
  io.write(text, " true \n")
 elseif bv == nil then
  io.write(text, " nil  \n")
 else
  io.write(text, " false\n")
 end
end
local a = {}
a["x"] = true
a["y"] = false
a["z"] = nil
writebool(lpdf.checkedkey(a,"x","boolean"),"lpdf.checkedkey(a,\"x\",\"boolean\")")
writebool(lpdf.checkedkey(a,"y","boolean"),"lpdf.checkedkey(a,\"y\",\"boolean\")")
writebool(lpdf.checkedkey(a,"z","boolean"),"lpdf.checkedkey(a,\"z\",\"boolean\")")
writebool(a.x,"a.x")
writebool(a.y,"a.y")
writebool(a.z,"a.z")
\stopluacode
TEST
\stoptext


It results in the following relevant output

lpdf.checkedkey(a,"x","boolean") true
lpdf.checkedkey(a,"y","boolean") nil
lpdf.checkedkey(a,"z","boolean") nil
a.x true
a.y false
a.z nil

Note that false value was read by checkedkey as nil.

Sincerely, MIchail


More information about the ntg-context mailing list