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

Consider LUA sigil turning script into chunk #35

Closed
Papipo opened this issue Aug 9, 2024 · 4 comments · Fixed by #36
Closed

Consider LUA sigil turning script into chunk #35

Papipo opened this issue Aug 9, 2024 · 4 comments · Fixed by #36

Comments

@Papipo
Copy link

Papipo commented Aug 9, 2024

I think that given that chunks are portable and don't need a state, it might be interesting to use luerl to turn ~LUA usages into Lua chunks. After all, it's inevitable that they will be loaded at some point, so why not have them converted to chunks already?

@davydog187
Copy link
Contributor

@Papipo i was planning on supporting this via a sigil modifier, e.g.

~LUA"foo()"c

What do you think?

@Papipo
Copy link
Author

Papipo commented Aug 9, 2024

Mmm, the only problem I see is that if there are functions that can receive both a string and a chunk you might forget to add the modifier and just carry strings instead of chunks.

@davydog187
Copy link
Contributor

Well, the reason why I didn't do this to start is that the sigil would need to return a tuple of the chunk and the Lua state, similar to Luerl.do

Given that the shape of the return value is much different, I'm not sure it's so much of a concern

@Papipo
Copy link
Author

Papipo commented Aug 12, 2024

Ah, true. I was thinking about luerl_comp.string, which doesn't need state. It might not be considered public API, though, but I think it's pretty slick to be able to carry portable chunks around.

There is also the option of making chunk the default and string the modifier. But that only makes sense if you can get the chunk without state (via the function stated above).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants