jgm / djot

A light markup language
https://djot.net
MIT License
1.67k stars 43 forks source link

README.md says djot is compatible with lua versions 5.1 to 5.4 but "goto" statement was defined in 5.2 #48

Closed ctp52 closed 2 years ago

ctp52 commented 2 years ago

The statement in README.md:

The code for djot (excluding the test suite) is standard Lua, compatible with 5.1–5.4, including luajit.

needs correcting to range over 5.2-5.4 as demonstrated by the Debian Linux version 11 lua package installing version 5.1.5 and an error is reported in djot/block.lua:

lua: error loading module 'djot.block' from file './djot/block.lua':
    ./djot/block.lua:683: '=' expected near 'finish'
stack traceback:
    [C]: ?
    [C]: in function 'require'
    ./djot.lua:1: in main chunk
    [C]: in function 'require'
    bin/main.lua:1: in main chunk
    [C]: ?

A new installation of lua version 5.4.4 behaves as expected.

jgm commented 2 years ago

I was misled on this because it works with luajit, which is basically lua 5.1, but apparently luajit backported some 5.2 extensions, including goto.

jgm commented 2 years ago

I'll keep this open because it might be worth rewriting to avoid the 'goto'. I didn't realize that debian stable still has lua 5.1.

ctp52 commented 2 years ago

Edgar Dijkstra's article from ACM in 1968 titled "Go To Statement Considered Harmful":

https://homepages.cwi.nl/~storm/teaching/reader/Dijkstra68.pdf

jgm commented 2 years ago

Yeah, I know. But this sort of use actually simplifies the code, as you can see from the changes I made to restore Lua 5.1 compatibility. (And we now test with all lua versions 5.1-5.4 and luajit on CI.)