can someone help me understand how *data-readers* are affecting eval ?
(let [expr [(java.util.Date.)]]
[(-> expr eval first type)
(binding [*data-readers* {'inst (comp java.util.Date/.toInstant clojure.instant/read-instant-date)}]
(-> expr eval first type))])
;; => [java.util.Date java.time.Instant]Eval works via compilation to buy code and running the bytecode
So when you eval something like a date, or some other arbitrary object, it needs to be serialized into something that can be used to reconstruct the object when bytecode runs
The way that works is the compiler calls pr-str on the object and stashes the string and when the bytecode executes it calls read-string
TIL
is that the relevant code? https://github.com/clojure/clojure/blob/6a4ba6aedc8575768b2fff6d9c9c7e6503a0a93a/src/jvm/clojure/lang/Compiler.java#L5459-L5481
Yes
alright, thanks for the explanation!
Updates: I was being an idiot and passed the wrong kind data as argument. Thank you @smith.adriane and @seancorfield for helping 🙏
Hey everyone I have some questions for
core.async which returns ArityException and other error where virtual thread didn’t.Note: I did ask lots of help from ChatGPT and Claude, since I very new to Clojure and core.async, so please bear with me.
Thank you for taking the time to answer my question 🙏
Based on the error message, I would guess that the error isn't related to core.async. Some function is getting a map instead of a string.
if you print out the full error message, it should give you a stacktrace with info about what function was expecting a string and which function was accidentally passing a map instead.
more generally, it seems like you might be interested in one of the pipeline functions in core.async
Thank you, there is no stack trace but repeated the error messages like the following
#object[clojure.core.async.impl.channels.ManyToManyChannel 0x75ebe7ea "clojure.core.async.impl.channels.ManyToManyChannel@75ebe7ea"]
clj꞉scraping꞉>
; Parsed html error: {:href #esc-signalling-issues, :text nil}Parsed html error: Parsed html error: {:href #inadequate-signaling-level, :text nil} class clojure.lang.PersistentArrayMap cannot be cast to class java.lang.String (clojure.lang.PersistentArrayMap is in unnamed module of loader 'app'; java.lang.String is in module java.base of loader 'bootstrap')
; Parsed html error: {Parsed html error: {:href ../_images/esc-signal.jpg, :text nil} class clojure.lang.PersistentArrayMap cannot be cast to class java.lang.String (clojure.lang.PersistentArrayMap is in unnamed module of loader 'app'; java.lang.String is in module java.base of loader 'bootstrap')
I am wondering if there are some issues within the scrape-chan itselfThose errors seem to have nothing to do with core.async -- is this code on GitHub where we can look at it?
The code you've posted references a lot of functions you don't show...
The complete stacktrace would help here...
*e in the REPL will show that.
Also, what is vehicle-type? You seem to pass v to process-url in the other function.
You mentioned ArityException but did not show that error -- that says one of your calls has the wrong number of arguments.
Sean, Thank you for replying, unfortunately I can’t post the whole code, but thanks for giving me some pointers so i can trace the error, and let me try that first
yea the ArityException seems to be gone, let me debug a with the *eand see if I can figure it out
because the weird part is scrape-vt and scrape-chan uses the same process-url and takes the same arguments but the outcome is different, which confuses me a lot
again thank you @smith.adriane and @seancorfield for giving me some pointers, i’ll try again tomorrow 😅