Hacker News new | ask | show | jobs
by _samt_ 12 days ago
That's an interesting idea.

Loading precompiled CLX modules is a different problem though. In theory, a native module could be loaded and executed with a restricted environment, similar to how Lua modules receive a specific `_ENV`.

It's not something CLX supports today, but it's much closer to the project's goals than runtime compilation of Lua source code.

One challenge is that standard Lua does not provide a way to change a function's `_ENV` after compilation (unlike the old `setfenv/getfenv` mechanism from Lua 5.1).

I've been considering adding environment manipulation capabilities to the CLX C++ API (while keeping Lua compatibility intact). If that happens, loading CLX modules into custom environments could become relatively straightforward.

1 comments

so a kind of setfenv type thing, but only from c++. That could work
Yes that's it