4 ms·
The cool thing is, there's no interop. It's literally JS or Lua. Think of it like CoffeeScript -- there's no "interop" between CoffeeScript and JS. It's just JS
by sillysaurus3 9y ago
The cool thing is, there's no interop. It's literally JS or Lua. Think of it like CoffeeScript -- there's no "interop" between CoffeeScript and JS. It's just JS.
You can see what each expression compiles to by passing it through (print (compile (expand ...)))
For example:
> ((require 'leftpad) "foo" 5)
"00foo"
> (print (compile (expand '((require 'leftpad) "foo" 5))))
require("leftpad")("foo", 5)
And of course, you can use macros to shorten this
> (define-macro see (x)
`(print (compile (expand ',x))))
(macro: function)
> (fn (x) (+ x 1))
function
> (see (fn (x) (+ x 1)))
function (x) {
return x + 1;
}
The best way to learn it is to read test.l and mess around with the expressions while running `make test` to see what breaks.
If you have questions, be sure to reach out or post them here. The maintainer is also quite responsive to opening new issues.
- rcarmo 9y agoBy interop I mean how to interact with existing functions (fine, most of the above covers that) and syntax for accessing data structures (arrays, tables, etc.).
- brandonhsiao 9y agoAlso, you can compile a Lumen file to JS/Lua by running `lumen -c file.l -o file.js`. More info at `lumen --help`.