Open audreyt opened 11 years ago
@DavidSouther introduced an --util
flag that removes inline references altogether: https://github.com/DavidSouther/LiveScript/commit/5a2a06fdd2a0805a7b65cdeb960cbbfa52b209de
It would make sense, then, to generate a util-ls
package (or have it as output of LiveScript.utils()
) so we can inline them in one place.
The --util functionality works by expecting the symbols needed to be on the global scope, either on GLOBAL or window. Will those definitions be available inside the worker, or will they be reinitialzed? I'll try and play around with it later today.
also, https://github.com/DavidSouther/LiveScript/commit/e01926ebb27e15e805403ce329e68c54e3c6ff5b is the commit with LiveScript changes.
Hi @DavidSouther -- if we have all utility functions accessible in string form, we can coax it into the webworker-threads context using w.thread.eval("function replace$ ...")
. Thanks for looking into it!
(Haven't forgotten about this, just been busy at work)
In code-injection contexts such as webworker-threads or plv8js, we couldn't simply inject the compiled function's string form into it, because import$ and replace$ etc are hoisted outside function scope.
Minimal example using webworker-threads:
Here the
-> x - /g/
is compiled toreturn replace$.call(x, /g/, '')
but replace$ is outside the thread scope and cannot be referred to.One way out of it may be a special literal UTILS that expands all utility functions
Another way may be a compilation mode that de-hoist the utilities and compile them into the function body.