pigpigyyy/Yuescript

do not expose global "yue"

johnd0e opened this issue · 3 comments

I noticed that using require("yue") not only returns the module, but also sets global yue variable:

> print(yue)
nil
> require"yue"
> print(yue)
table: 0x00698928

Is that intended?

Yes, it's intended and done by the Lua C-API from here for Lua version above 5.1

luaL_requiref(L, "yue", luaopen_yue, 1);

and here for Lua 5.1
luaL_register(L, "yue", yuelib); // yue

So you think it is more of polluting the global env instead of offering convenience?

So you think it is more of polluting the global env instead of offering convenience?

Yes, exactly, that is my opinion.

OK, got this issue fixed by lastest commit. After all, it won't cost much effort to manually expose yue as global variable.