lua-users home
lua-l archive

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


Just to clarify because you mentioned it, break statements being able to be placed anywhere in LuaJIT is only enabled if it is built with -DLUAJITENABLE_LUA52COMPAT. (you can see this on the Extension page on the luajit website.)

On Tue, Jul 26, 2022 at 6:24 PM Paul Ducklin <pducklin@outlook.com> wrote:
LuaJIT supports "goto" yet doesn't allow
> break as non-last statement in a block

IIRC the OP’s question was about Lua (not LuaJIT, which is a different product on a totally different and incompatible trajectory), and why this grammar change might have arrived after version Lua 5.1.

The forward goto means that it became possible to have code inside a block but after a break that wasn’t dead code… thus my guess that this might be why the Lua compiler changed.

Anyone from PUC Rio care to talk us through it?

Numerous things were put into Lua that LuaJIT excluded as unnecessary, impure, incorrect or simply not part of LuaJIT’s chosen alternative direction (bitops and 64-bit integers coexisting with floating point numbers are two examples; if memory serves, the new-at-the-time _ENV system was another). So “what feature X ended up looking like in LuaJIT” basically tells you nothing about  “the reason why a feature X ended up in Lua”, given that the LuaJIT project turned off onto its own, independent and divergent branch line many years ago.

(Not being judgmental, though my personal preference is for Lua and I have never needed or used LuaJIT. Just mentioning this because a lot of Lua newcomers seem to assume that LuaJIT is to Lua like Kubuntu is to Ubuntu, and compare or contrast them accordingly.)