Open creationix opened 8 months ago
Hi! Thanks for looking at Teal :) @fperrad has also asked for this recently, and even sent a PR... At the time, I declined having this behavior be automatic, and wrote down my reasoning: https://github.com/teal-language/tl/pull/686
I'm not 100% opposed to making this into a compiler option (cautiously saying this while being afraid of opening Pandora's Box) but I still want Teal's default behavior to be as consistent as possible on every supported Lua version (within some pragmatic limits).
At this time, with an unmodified tl
, I just patch the generated files with a simple command sed -e 's/bit32/bit/g;'
.
Maybe add bit
checking along with bit32
checking in generated file, like this.
local bit32 = bit32; if not bit32 then local p, m = pcall(require, 'bit32'); if p then bit32 = m elseif p, m = pcall(require, 'bit'); if p then bit32 = m end end end; --...
I understand the fear of opening Pandora's box, but I'd really like to be able to have something like teal for luajit based runtimes. Lua is just too slow for the types of projects I work on and the main drawback of luajit is the lack of proper types in the tooling. Native teal support for luvit and openresty apps would be amazing!
Creating a competing teal-like project that targets luajit seems silly and a waste of effort. I hope there is a way to support luajit properly without causing undue burden on this project.
@creationix Thanks again for the feedback. I think a way out of this conundrum (and similar ones in general) will be to introduce compiler flags not only at the CLI level, but at the module-file level as special comments, like https://wiki.haskell.org/Language_Pragmas (related: https://github.com/seanbaxter/circle/blob/master/new-circle/README.md#versioning-with-feature-directives )
I would love to be able to use teal with luajit based runtimes. As you know, luajit has a nice bit library built-in that is the same or very similar as
bit32
. I need a way to configure luajit as the runtime that tweaks the generated code.