Oh I do care, the result is a side effect though (slack message)
I don't keep a reference to the future, nor do I wanna block on it
I very often get the following genre of error
actual: java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol
at clojure.lang.RT.seqFrom (RT.java:553)
clojure.lang.RT.seq (RT.java:533)
clojure.core$seq__5387.invokeStatic (core.clj:137)
clojure.core$empty_QMARK_.invokeStatic (core.clj:6206)
clojure.core$empty_QMARK_.invoke (core.clj:6206) clojure_rte.genus_spec$eval17078$_spec_to_rte__17079$strip_keys__17105.invoke (form-init10191085421504055651.clj:122) clojure_rte.genus_spec$eval17078$_spec_to_rte__17079$specify__17080$iter__17081__17085$fn__17086.invoke (form-init10191085421504055651.clj:103)
clojure.lang.LazySeq.sval (LazySeq.java:42)
clojure.lang.LazySeq.seq (LazySeq.java:51)
clojure.lang.Cons.next (Cons.java:39)
clojure.lang.RT.next (RT.java:709)
It seems it would be helpful if the error message would tell me which symbol is problematic. I think this means a destructuring somewhere has failed. If it told me the symbol, then it would be easier to pinpoint in my code.
In this case I see the following in the stacktrace. clojure_rte.genus_spec$eval17078$_spec_to_rte__17079$strip_keys__17105.invoke
Indeed I have a function spec-to-rte
which has a local function named strip-keys
defined by letfn
. However, I don't see any destructuring in that local function.In the meantime https://github.com/jpmonettas/flow-storm is good at showing you what happened up until the error occurred
The https://clojuredocs.org/clojure.core/letfn`letfn` says I cannot put :pre and :post conditions on local functions. Is that intentional? I often use :pre conditions while debugging.
@andy.fingerhut good point about experimentation.
Hello, i am new to Programming overall i only know a bit JS and mediocre elisp since I am using alot of Emacs for Work. I plan to create a small to medium personal webproject - I dont know if Clojure is suited well for that but where would be a good starting point?
Sounds like a nice project. In my opinion there’s no size-limit when “clojure starts to make sense”. Once you grasp the repl-driven workflow and the immediate feedback that comes with it, there’s no going back. 🙂 …or in your case if you once try another kind of approaches, they will probably feel less productive and less satisfying. I’d suggest starting with the frontend (using ClojureScript) because there you actually see the changes as you write the code. Then adding a Clojure backend component for storing the data, creating PDF’s etc. Luminus will probably help you get started fast with the whole stack (clojure backend + clojurescript frontend).
Would you recommend any books? free and non-free?
@thomasfuston I have a few free books here that I am continually adding too https://practicalli.github.io/
@jr0cket thx for the link and work! I will take a look
There is a #practicalli channel here if you have any questions about the books
I do not see any mention of pre or post conditions at all in that documentation. It does not say you cannot. It does not say anything about them.
But agree they are absent from that documentation, from which one might guess they cannot be supplied.
It really only takes a minute or two to experiment and see whether they work or not, in a REPL.
In my several-minute experiment, they are supported inside of functions defined within leftfn
That error can occur with no destructuring occurring, too.
For example:
user=> (seq 'a)
Execution error (IllegalArgumentException) at user/eval184 (REPL:1).
Don't know how to create ISeq from: clojure.lang.Symbol
user=> (filter even? 'a)
Error printing return value (IllegalArgumentException) at clojure.lang.RT/seqFrom (RT.java:557).
Don't know how to create ISeq from: clojure.lang.Symbol
user=> (map identity 'a)
Error printing return value (IllegalArgumentException) at clojure.lang.RT/seqFrom (RT.java:557).
Don't know how to create ISeq from: clojure.lang.Symbol
Note that the symbol in question might not occur in your source code anywhere, e.g. it could be read from input.
Clojure works well for web-development. What kind of a project are you planning?
Hi, I am newbie in Clojure so my question might be very stupid. Suppose thread A wants to set an atom x
to 5 and thread B wants to set it to 6. We expect the value to be 5 first and 6 after. Thread A though is blocked and retried after thread B, the value of x
would then be 6 first and then 5. How is consistency assured with atom
when a retry happens?
@francesco.losciale what do you mean by threads? i never use forking in clojureland
Compare and set is a common idiom to the point where most processors actually implement an equivalent instruction
The retry is not around the setting, but the entire operation
why do you expect the value to be 5 first then 6? the atom will ensure that the operations are applied atomically, but I don't see anything in your description that would imply or impose ordering
1. Read value 2. Apply function to get new value 3. Set new value if nothing has changed or go-to 1
Depends on how much you want to make from scratch and how much you want to use an existing template for... z
Luminus, Fulcro, are both options for applications You could also simply start with an http-server like clj/ring or http-kit and then build a website from a basic server with HTTP requests/responses
I am thinking of a use case in which the state can only be increased, for example. If it changes to 6 and then to 5, the first “thread” might run logic thinking the state is 6.
Is it implied the functions that change the state are always commutative?
oh, ok! here's the equivalent code
(def x (atom 4))
;; on thread A
(swap! x inc)
;; on thread B
(swap! x inc)
it's guaranteed that the value in the atom x
, will be 5 and then 6, but it's not guaranteed which thread will have its operation completed first. as @hiredman said, atoms use CAS to ensure consistency. the wikipedia page has a decent explanation, https://en.wikipedia.org/wiki/Compare-and-swapyou can find clojure's implementation https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Atom.java#L34
public Object swap(IFn f) {
for(; ;)
{
Object v = deref();
Object newv = f.invoke(v);
validate(newv);
if(state.compareAndSet(v, newv))
{
notifyWatches(v, newv);
return newv;
}
}
}
Hello, I'm starting the book Programming Clojure by Alex Miller. I'm trying to run (require '<http://clojure.java.io|clojure.java.io>')
. I've started a repl using the lein repl
command. I know little about Java and the error I'm getting hasn't been useful so far. Here's the error:
Could not locate clojure/java/io'__init.class, clojure/java/io'.clj or clojure/java/io'.cljc on classpath.
I'd also like to run the example from the code samples that can be found here: http://media.pragprog.com/titles/shcloj3/code/shcloj3-code.zip. (require 'examples.introduction')
gets me a similar error.
How can I fix this error?eNo single quote after http://clojure.java.io
It is not a string, but a symbol. A leading single quote in Clojure means that the following expression should not be evaluated.
Thank you so much!