kanaka / clojurescript Goto Github PK
View Code? Open in Web Editor NEWThis project forked from clojure/clojurescript
Clojure to JS compiler (patched to allow compiling of compiler to ClojureScript)
This project forked from clojure/clojurescript
Clojure to JS compiler (patched to allow compiling of compiler to ClojureScript)
Currently, the / symbol is removed from the namespaces snapshot during compile. If it's added back in like this:
--- a/src/clj/cljs/compiler.clj
+++ b/src/clj/cljs/compiler.clj
@@ -784,8 +784,7 @@
(defn ns-snap [ns]
(let [nss1 (dissoc (get @ana/namespaces ns) :requires-macros)
- nss2 (read-string (pr-str (update-in nss1
- [:defs] dissoc '/)))]
+ nss2 (read-string (pr-str nss1))]
(apply str
(emit (ana/analyze (ana/empty-env)
(list 'swap! 'cljs.core/namespaces 'assoc (list 'quote ns) (list 'quote nss2)))))))
Then the compile throws an exception:
Exception in thread "main" java.lang.RuntimeException: Invalid token: cljs.core//
at clojure.lang.Util.runtimeException(Util.java:170)
at clojure.lang.LispReader.interpretToken(LispReader.java:321)
Also, it's likely that in core.cljs, the namespace and name functions will need to be fixed once the above works. For example, (namespace 'cljs.core//) gives "cljs.core/" because it is looking for the last /.
ClojureScript:
cljs.user=> 0x7e7
ERR: Error: Invalid number format [0x7e7] at line 0
ERR: at reader_error__delegate (../cljs/reader.js:217:8)
...
Clojure:
user=> 0x7e7
2023
The code base was forked from upstream ClojureScript several months ago and has not been merged with it since then.
One of the big features that is being added to upstream ClojureScript is source maps which would be a big benefit to cljs-in-cljs too.
Note that compiler.cljs and analyzer.cljs were copied from compile.clj and analyzer.clj so in addition to merging the *.clj versions, the changes will need to also be ported to the *.cljs versions of those files.
cljs.user=> :a
:a
cljs.user=> :2
ERR: TypeError: Cannot read property '0' of null
ERR: at read_keyword (../cljs/reader.js:669:19)
...
Numeric keywords work in normal Clojure.
And just for fun, here is a syntax quote/unquote diagram: http://www.thelastcitadel.com/images/syntax.png
I am new to closurescript, and this looks like a really cool project I would like to try to get running. I am particularly interested in the feature "You can have a ClojureScript REPL web app that runs locally in your browser (no server involved after loading the page)"
I cloned and followed the instructions to build the webrepl using steps below:
cd web
../bin/cljsc ../src/cljs/webrepl.cljs > webrepl.js
But when loading jsrepl.html I get the error "Uncaught Error: Undefined nameToPath for cljs.repl. (base.js:586)" I saw an older issue that was answered with a need to run the bootstrap script, which didn't help me. It seems like it is unclear what to use from the main clojurescript project, versus this patch to make it possible to run the repl native in the browser as in your demo.
It seems like I am missing a step for how to build all of the js files needed to run the webrepl (for example cljs/repl.js). I also tried manually building everything from the src directory using the various dependencies (starting from webrepl.js) but hit trouble when building the compiler.js with the included cljsc (which I am assuming is the future enhancement to compile itself, so what am I missing to get this working? Any advice would be greatly appreciated. I would be happy to update instructions if something has changed to get it working or if there is an assumption I am missing, etc. Any ideas where I went wrong with getting it running?
Looks like cljs format
uses google clojuse stringformat that implements python like formatting instead of Java like one, which can cause issues like #10
ClojureScript:
cljs.user=> (#(prn %) 1 2)
1
cljs.user=> (#(prn %1 %2) 1)
1 nil
Clojure:
user=> (#(prn %) 1 2)
ArityException Wrong number of args (2) passed to: user$eval2$fn clojure.lang.AFn.throwArity (AFn.java:437)
user=> (#(prn %1 %2) 1)
ArityException Wrong number of args (1) passed to: user$eval8$fn clojure.lang.AFn.throwArity (AFn.java:437)
I believe this is a goal, but not sure what's are the blockers to get there. Maybe we can discuss and link remaining issues here.
Implementing tagged reader literals is the only thing remaining that will allow cljs-in-cljs to compile and run all the tests in test/cljs/cljs/core_test.cljs
.
Hi. This project looks neat, but looks like it has gone stagnant. How come development has stopped? Are there any new projects adressing the goals of this?
I am having trouble getting this to work.
I cloned it as is.
When run the first command: ../bin/cljsc ../src/cljs/webrepl.cljs > webrepl.js
I get: Error: Could not find or load main class clojure.main
I am trying to get core.async built with the compiler in the cljsc-in-cljsc tree. It looks like it takes exception to the js
namespace for catch.
https://github.com/clojure/core.async/blob/master/src/main/clojure/cljs/core/async.cljs#L700
(catch js/Object e
(swap! dctr dec))))
The output given is:
Exception in thread "main" java.lang.AssertionError: Assert failed: Can't qualify symbol in catch
(not (namespace name))
at cljs.analyzer$eval124$fn__126.invoke(analyzer.clj:284)
at clojure.lang.MultiFn.invoke(MultiFn.java:241)
at cljs.analyzer$analyze_seq.invoke(analyzer.clj:898)
at cljs.analyzer$analyze.invoke(analyzer.clj:953)
at cljs.analyzer$analyze_seq.invoke(analyzer.clj:900)
Looking at the analyzer.js
code, it looks like we have a few special exceptions for namespace references to js
-- I will see if I can get this to understand that it can ignore a namespace of 'js', but hints would be appreciated.
The new UI from the Himera site uses jquery.console for the interactive part (and history). It looks nice but has some usage annoyances:
* long-lines can cause the cursor to disappear until you hit enter
* selecting text will immediately unselect making copy difficult
* using middle click (in X) to paste doesn't work (Ctrl-V paste does work)
I'm hoping to use this project to get some quick and dirty .js from .cljs in the context of a node project. I can't run any of the examples, e.g.
cd node
../bin/cljsc ../src/cljs/nodecljs.cljs > nodecljs.js
I get
Exception in thread "main" java.lang.NoClassDefFoundError: clojure/main
Caused by: java.lang.ClassNotFoundException: clojure.main
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
There's no project.clj so lein deps can't be the answer. . . halp?
thanks.
cljs.user=> (mod -3 12)
-3
The correct answer should be 9.
ClojureScript (with debug enabled):
cljs.user=> "ü"
READ: "ü"
ANALYZED: "ü"
EMITTED: "\"\\u%04X\""
ERR: SyntaxError: Unexpected token ILLEGAL
...
Clojure:
user=> "ü"
"ü"
The web editor Pentadactyl has a feature for eval-ing javascript source files. I tried to eval the files of the demo to obtain the repl but with not luck. Any little bit of documentation about it would be welcome.
There are several places where we need to catch exceptions during compilation and at least report line numbers (whole line and/or form would be useful to when possible).
The cljs-in-cljs compile is slower than the regular ClojureScript compiler. I suspect there are some low hanging fruit that could be addressed easily to increase performance. Using profiling tools might reveal some areas to address.
Also, another area of interest would be to add support for output of asm.js code: http://asmjs.org/, http://asmjs.org/spec/latest/ This could potentially result in significant speedups especially for the persistent data structure implementations.
For example, this works:
cljs.user=> (load-file "../test/cljs/cljs/quick.cljs")
cljs.user=> (in-ns 'cljs.test.quick-tests)
cljs.user=> (run-tests)
However, this does not:
cljs.user=> (load-file "../test/cljs/cljs/quick.cljs")
cljs.user=> (cljs.test.quick-tests/run-tests)
#<Error: Assert failed: (= *ns-sym* (symbol (namespace :G__1/foo)))> at line 1
I cannot build using ./script/compile
; I get this:
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 1879048192 bytes for committing reserved memory.
Unfortunately, my computer has only 2GB of RAM. Any suggestions on how to get this to build?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.