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

module and require not available #26

Closed
71104 opened this issue Dec 27, 2014 · 6 comments
Closed

module and require not available #26

71104 opened this issue Dec 27, 2014 · 6 comments
Assignees
Labels

Comments

@71104
Copy link
Owner

71104 commented Dec 27, 2014

They should be available when running from the REPL, but they aren't (not sure why).

This is secondary if the main use of the language is to transpile to JavaScript.

@71104 71104 added the bug label Dec 27, 2014
@71104 71104 self-assigned this Dec 27, 2014
@71104
Copy link
Owner Author

71104 commented Dec 28, 2014

Neither Math's methods are...

@71104
Copy link
Owner Author

71104 commented Dec 31, 2014

They might be available through global, which in turn is not currently available due to #27.

@71104
Copy link
Owner Author

71104 commented Jul 9, 2015

Now that #27 is fixed global is available but module and require are not.

@71104
Copy link
Owner Author

71104 commented May 17, 2016

This one strikes back.

Eventually, the solution adopted to make module and require available to the global scope (when running Lambda programs in the interpreter) was to invoke eval with the variable name.

This had the nasty side effect of making lots of other internal variables available to the global scope of Lambda programs: all the Lambda namespace and all the variables available in the specific point of the Lambda interpreter code where eval was invoked.

This has been reverted by 2f66282, and now module and require are no longer accessible.

These two variables are defined in a very weird way in Node.js, and the only solution here is to provide an ad hoc solution, i.e. making them explicitly available when running in interpreter mode.

@71104 71104 reopened this May 17, 2016
@71104
Copy link
Owner Author

71104 commented May 17, 2016

module and require are still indirectly accessible through process.mainModule and process.mainModule.require, respectively.

71104 added a commit that referenced this issue May 18, 2016
@71104 71104 closed this as completed in 5d316a9 Sep 23, 2016
@71104
Copy link
Owner Author

71104 commented Sep 23, 2016

5d316a9 introduces a command line switch n that enables "NodeJS mode". In NodeJS mode the interpreter has types and unmarshalled values for module and require.

Note that, for convenience, require requires only one string argument rather than this and an array of arguments, like other native closures. Example:

~/lambda$ npm start -- -n
> let fs = require 'fs' in fs.readdirSync {'.'}
{'.git', '.gitattributes', '.gitignore', 'Doxyfile', 'Gulpfile.js', 'LICENSE', 'README.md', 'bin', 'doc', 'node_modules', 'package.json', 'src', 'test'}
> 

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

No branches or pull requests

1 participant