Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support luajit native bit library instead of bit32 #723

Open
creationix opened this issue Nov 3, 2023 · 6 comments
Open

Support luajit native bit library instead of bit32 #723

creationix opened this issue Nov 3, 2023 · 6 comments
Labels
feature request New feature or request semantics Unexpected or unsound behaviors

Comments

@creationix
Copy link

creationix commented Nov 3, 2023

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.

@euclidianAce euclidianAce transferred this issue from teal-language/cyan Dec 7, 2023
@hishamhm hishamhm added feature request New feature or request semantics Unexpected or unsound behaviors labels Dec 11, 2023
@hishamhm
Copy link
Member

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: #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).

@fperrad
Copy link
Contributor

fperrad commented Dec 12, 2023

At this time, with an unmodified tl, I just patch the generated files with a simple command sed -e 's/bit32/bit/g;'.

@mbekkomo
Copy link

mbekkomo commented Jun 1, 2024

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; --...

@creationix
Copy link
Author

creationix commented Jun 12, 2024

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.

@hishamhm
Copy link
Member

@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 )

@hishamhm
Copy link
Member

see #751

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request semantics Unexpected or unsound behaviors
Projects
None yet
Development

No branches or pull requests

4 participants