lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

To Antonio, and CC:ing to both ConeOfSilence and the entire topic
of "Number? Integer? Double?" (albeit in a slightly different context)
is being debated on the lua-l list:

On 1/7/22 23:18, Antonio Scuri wrote:
>   I think that is just a error in the script. canvas.Line expects an integer and it is used a floating point. In Lua 5.3 integers have a better support so it is warning you that you are not using an integer I guess. I didn't further investigate. 
> Em ter., 4 de jan. de 2022 às 23:01, sur-behoffski < <>> escreveu:
>     On 1/5/22 10:44, ConeOfSilence wrote:
>     > Thank you for the detailed response! I was able to get things built on my Linux Mint machine. I had to run the svn-checkout steps a few times due to the timeout issue.
>     >
>     > The ./cdpdf.lua did crash.
>     > ../support/lua5.3: ./cdpdf.lua:45: bad argument #1 to 'Line' (number has no integer representation)
>     > stack traceback:
>     > [C]: in method 'Line'
>     > ./cdpdf.lua:45: in main chunk
>     > [C]: in ?
>     >
>     > Are there any plans to support Debian based distributions?
>     >

Okay, I've spent a bit of time examining the Canvasdraw-CD online
documentation, and the result is unambiguous:  The documentation
consistently uses a type called "number", both for parameters going
into, and results coming out of, the Lua interface to the C code.

A careful reading of the CD WebBook: "CD->Canvas->Coordinate System"
backs up this determination.

One example:

  > void cdCanvasPixel2MM(cdCanvas* canvas, int dx, int dy, double *mm_dx, double *mm_dy); [in C]
> void cdfCanvasPixel2MM(cdCanvas* canvas, double dx, double dy, double *mm_dx, double *mm_dy); [in C]
> canvas:Pixel2MM(dx, dy: number) -> (mm_dx, mm_dy: number) [in Lua]
> canvas:fPixel2MM(dx, dy: number) -> (mm_dx, mm_dy: number) [in Lua]
> Converts sizes in pixels (canvas coordinates) into millimeters. You can provide only the desired values and NULL for the others. Use this function to obtain the horizontal and vertical resolution of the canvas by passing 1 as parameter in dx and dy. The resolution value is obtained using the formula res=1.0/mm.

The documentation plays fast and loose with the meaning and role
of "number" in the Lua interface... no wonder that "Lua 5.1"
"works", whereas "Lua 5.3" can "break".


1. Fix the documentation; and/or

2. Rework the interface to allow Lua 5.1-like behaviour, across
all Lua versions, especially Lua 5.3 and 5.4, where explicit
integers were introduced.


sur-behoffski (Brenton Hoff)
programmer, Grouse Software