[NTG-context] integer displayed as .0 float in Lua-5.3

Hans Hagen j.hagen at xs4all.nl
Thu Aug 9 22:25:47 CEST 2018

On 8/9/2018 10:00 PM, Pablo Rodriguez wrote:
> On 08/09/2018 09:34 PM, Alan Braslau wrote:
>> The lua manual also states that one should NOT rely on the implicit
>> conversion of a string to its numerical value, and suggests the
>> systematic use of tonumber().
> Many thanks for your reply, Alan.
> I guess that backwards compatibility should be important here, but I
> hope there are stronger reasons for breaking it.
> Many thanks for your help,
In addition to what others already explained, you should not depend on 
features that are implementation dependent or might disappear. That said 


Why do you convert \lastpage to a string using [[\lastpage]] which will 
use the string to number conversion. In fact this automatic cast from 
string to number in an addition might disappear from the language in the 
future so don't rely on that.

You can just do:

\ctxlua{context(\lastpage + 1)}.

Or when in dount about what \lastpage is

\ctxlua{context(\number\lastpage + 1)}.

or if you really want to [[ ]]

\the\numexpr\ctxlua{context([[lastpage]] + 1)}\relax .

endless possibities here.


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

More information about the ntg-context mailing list