ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Peter Rolf <indiego@gmx.net>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: lpdf.checkedkey has problem with false values
Date: Mon, 15 Sep 2014 16:59:56 +0200	[thread overview]
Message-ID: <5416FEEC.7080704@gmx.net> (raw)
In-Reply-To: <CALDha9MmfXjxcTkXbM_G_2P-ANXc67Ydp5P0gXTLj2JOG5uryA@mail.gmail.com>

Am 15.09.2014 um 16:14 schrieb Michail Vidiassov:
> 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?

More a lua design decision. 'nil' is equal to 'false' here, 'true' is
equal to all that is not 'nil'.

http://www.lua.org/pil/3.3.html

> (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

if bv then

>   io.write(text, " true \n")
>  elseif bv == nil then

else
(if not bv then)


HTH,   Peter


>   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
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
> 
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
> archive  : http://foundry.supelec.fr/projects/contextrev/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________
> 

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


  reply	other threads:[~2014-09-15 14:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-15 14:14 Michail Vidiassov
2014-09-15 14:59 ` Peter Rolf [this message]
2014-09-15 15:34   ` Michail Vidiassov
2014-09-15 15:56     ` Aditya Mahajan
2014-09-15 16:12       ` Michail Vidiassov
2014-09-15 17:12         ` Hans Hagen
2014-09-15 18:25           ` Michail Vidiassov
2014-09-15 19:17             ` Hans Hagen
2014-09-16  3:33               ` Michail Vidiassov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5416FEEC.7080704@gmx.net \
    --to=indiego@gmx.net \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).