Fork me on GitHub
#beginners
<
2020-11-07
>
Jim Newton08:11:44

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.

andy.fingerhut13:11:05

That error can occur with no destructuring occurring, too.

andy.fingerhut13:11:27

For example:

user=> (seq 'a)
Execution error (IllegalArgumentException) at user/eval184 (REPL:1).
Don't know how to create ISeq from: clojure.lang.Symbol

andy.fingerhut13:11:59

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

andy.fingerhut13:11:30

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

andy.fingerhut13:11:47

Note that the symbol in question might not occur in your source code anywhere, e.g. it could be read from input.

Adrian Smith22:11:28

In the meantime https://github.com/jpmonettas/flow-storm is good at showing you what happened up until the error occurred

Jim Newton10:11:58

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.fingerhut13:11:17

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.

andy.fingerhut13:11:46

But agree they are absent from that documentation, from which one might guess they cannot be supplied.

andy.fingerhut13:11:15

It really only takes a minute or two to experiment and see whether they work or not, in a REPL.

andy.fingerhut13:11:23

In my several-minute experiment, they are supported inside of functions defined within leftfn

✔️ 3
Jim Newton15:11:04

@U0CMVHBL2 good point about experimentation.

Lemonski12:11:20

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?

valtteri15:11:48

Clojure works well for web-development. What kind of a project are you planning?

sova-soars-the-sora18:11:35

Depends on how much you want to make from scratch and how much you want to use an existing template for... z

sova-soars-the-sora18:11:40

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

Lemonski07:11:50

@U6N4HSMFW The Project itself is a Colordatabase for painters with features like create your own palette and download a pdf of it and if possible current prices in the most known shops. Maybe Clojure is overkill for such a small need?

Lemonski07:11:03

@U3ES97LAC Since i basically would start from almost 0 prior programming (besides elisp) i would prefer some leads and templates, luminus looking promising, Got both "frameworks" saved for later when i know a little more clojure

valtteri08:11:35

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).

Lemonski09:11:08

Would you recommend any books? free and non-free?

practicalli-john10:11:17

@U01EENTKD0C I have a few free books here that I am continually adding too https://practicalli.github.io/

Lemonski10:11:54

@U05254DQM thx for the link and work! I will take a look

practicalli-john10:11:45

There is a #practicalli channel here if you have any questions about the books

gibi18:11:31

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?

hiredman18:11:57

Compare and set is a common idiom to the point where most processors actually implement an equivalent instruction

hiredman18:11:42

The retry is not around the setting, but the entire operation

phronmophobic18:11:50

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

hiredman18:11:40

1. Read value 2. Apply function to get new value 3. Set new value if nothing has changed or go-to 1

gibi18:11:49

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.

gibi19:11:18

Is it implied the functions that change the state are always commutative?

phronmophobic19:11:40

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 @U0NCTKEV8 said, atoms use CAS to ensure consistency. the wikipedia page has a decent explanation, https://en.wikipedia.org/wiki/Compare-and-swap

phronmophobic19:11:40

you 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;
			}
		}
}

👍 3
sova-soars-the-sora18:11:47

@francesco.losciale what do you mean by threads? i never use forking in clojureland

greg22:11:46

Hello, I'm starting the book Programming Clojure by Alex Miller. I'm trying to run (require '') . 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?e

andy.fingerhut22:11:55

It is not a string, but a symbol. A leading single quote in Clojure means that the following expression should not be evaluated.

greg22:11:14

Thank you so much!