clj -M --main cljs.main --compile foo.core --repl
works fine to open a repl connected to a browser and im able to run my code
but when i try clj -M --main cljs.main --repl-env node --compile foo.core --repl
the repl loads (without the browser) but i can’t run my code.
`Execution error (ReferenceError) at (<cljs repl>:1).
foo is not defined`
Maybe ask in #clojurescript
i did at first but felt it was such a newb question i moved it here! 🙂
i also wonder if the answer is “if you’re not using the browser, just use clojure”…
Hah that is definitely an answer. You could write everything in cljc and use the Clojure repl, provided you don’t need any features of node (fs, event emitter etc)
yeah i don’t need any of that
@evanhaveman Something worth bearing in mind is that ClojureScript has to go through a compile-to-JS phase, which requires the ClojureScript compiler which is running on the JVM anyway. So if you don’t need a browser and you don’t need Node.js features, I would probably just write it as .cljc
files, run it on the JVM as Clojure while you’re developing stuff, and use Olical’s cljs-test-runner
to make sure it compiles and runs as ClojureScript. That’s what I do for HoneySQL (on the v2 branch).
thank you - i’ll look into cljs-test-runner!
@jimmyssj3 Atom is implemented in such a way that JVM ensures that any successful write will be seen by any subsequent reads in other threads. Lock-free update mechanics are possible because of CAS, compare and swap. 1. Thread reads "current value" of the atom as a "last known" 2. Runs a function to produce a "new value" 3. Tries to swap "current value" by the "new value" 4. If "current value" equals to "last known" value, "new value" is written, else, another thread was faster to update the value and current thread should retry the whole process. (Hence no side-effects requirement for a "new value" function)
Here is an example of 100 threads doing 10k increments each to the integer stored in the atom.
(defn test-atom [nthreads niters]
(let [ref (atom 0)
pool (Executors/newFixedThreadPool nthreads)
tasks (repeat nthreads #(dotimes [_ niters]
(swap! ref inc)))]
(doto pool
(.invokeAll tasks)
(.shutdown)
(.awaitTermination 60 TimeUnit/SECONDS))
@ref))
=> #'user/test-atom
(test-atom 100 10000)
=> 1000000
You may wan't to dig deeper into JVM memory model to understand the foundation clojure is built on, but that isn't strictly necessary. https://shipilev.net/blog/2014/jmm-pragmatics/
Hi im trying to use simple-v-table
in re-com
but I keep getting this issue re_com.v_table.v_table(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.
I know I am probably missing something - where a simple h-box
is different from simple-v-table
but I don't know what I might be missing?
okay turns out I missed out a dependency for v-table :face_palm:
Hey! I remember seeing a way to work with time in Clojure/Clojurescript that enabled using EDN reader literals (?) for serialization. So that when exporting a semantic type for time/datetime, you'd get something like
#library-provided-tag "time representation with string"
;; or
#library-provided-tag {:minutes 33 :hours 1231 :other-stuff "perhaps?"}
, which you could print to the REPL and read back in, serialize and deserialize with EDN, etc.
Does this sound familiar to anyone of you? Thanks!Thanks again @seancorfield and @alexmiller (as well as others) for your responses here. They have been helpful in a brief time in Clojure. Unfortunately (and fortunately), I have found an interesting position with another company doing low level, open source, system monitoring code but its primarily Java with some Kotlin and Scala among other languages. So my 2 months doing full stack Clojure has been fun and I hope to return to it again someday. Take care ya’ll and see you later.
Nice, thanks!
What’s the ‘right way’ to support a list of things that may have one or two elements, and basically if each sublist is one element, reuse the first element.
(def files [["src1" "dst1'] ["src2']])
(doseq [[src dst] files]
(let [dst (or dst src)]
...
What's the place for Clojure feature requests again?
http://ask.clojure.org is a good place for questions like that
Hi, what does
2021-05-15 09:42:27.928:WARN:oejs.HttpChannel:qtp314487999-538: handleException /audiofile-here.m4a java.io.IOException: java.util.concurrent.TimeoutException: Idle timeout expired: 200000/200000 ms
mean?nevermind. I found the facts: the stack trace indicates that the server was writing some content, but the TCP connection got congested, so the write http://blocked.To unblock the congestion, the client must read (and communicate that to the server via TCP ACKs). Apparently this did not happen for 30 seconds, so Jetty closed the connection due to idle timeout.
not really following but maybe use last
?
thanks added a request, upvote if you suffer from ^"[Lridiculously.verbose.type.Hints;" too https://ask.clojure.org/index.php/10609/into-array-should-not-need-type-hints
No, basically I want if the second element is there then use it, otherwise use the first again
user=> (def files [["src1" "dst1"] ["src2"]])
#'user/files
user=> (defn copy [src dst] (println "copying" src "to" dst))
#'user/copy
user=> (doseq [[src dst] files
:let [dst (or dst src)]]
(copy src dst))
copying src1 to dst1
copying src2 to src2
oh cool, I didn’t know about :let
. Is the dst (or dst src)
idiomatic?