6 Implementing Javascript Modules
Warning: the material in this section is unstable and likely to change.
6.1 Module Implementation in Javascript
(require (planet dyoo/js-vm:1:11/lang/js-impl/js-impl)) |
This module allows the definition of modules whose implementations
are written in Javascript.
As an example, the following two files provide an implementation
of double in Javascript:
// double.js |
EXPORTS['double'] = |
new types.PrimProc('double', 1, false, false, function(x) { |
return jsnums.multiply(x, 2)}); |
Any module implemented with (planet dyoo/js-vm:1:11/lang/js-impl/js-impl) will provide bindings that require a Javascript context.
6.2 Conditional Module Implmentation in javascript
(require (planet dyoo/js-vm:1:11/lang/js-impl/js-conditional)) |
Any module implemented with (planet dyoo/js-vm:1:11/lang/js-conditional/js-conditional) can run either in a Racket or Javascript context.