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

require should return the loaded module #26

Open
graue opened this issue Feb 26, 2013 · 0 comments
Open

require should return the loaded module #26

graue opened this issue Feb 26, 2013 · 0 comments

Comments

@graue
Copy link

@graue graue commented Feb 26, 2013

I've noticed that when calling require from Lua.js, it doesn't return anything. The code inserted into each compiled Lua module is:

G.str['require'] = function (name) {
  lua_require(G, name);
};

Lua's reference manual states that require should return a value:

Once a loader is found, require calls the loader with a single argument, modname. If the loader returns any value, require assigns the returned value to package.loaded[modname]. If the loader returns no value and has not assigned any value to package.loaded[modname], then require assigns true to this entry. In any case, require returns the final value of package.loaded[modname].

Lua.js isn't doing the bolded part.

I may submit a patch for this if I can figure it out. This is part of my attempt to get the table method of defining a module to work in Lua.js (see #13).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.