clojure

mkvlr 2025-10-22T00:14:36.285239Z

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]

2025-10-22T00:40:20.504029Z

Eval works via compilation to buy code and running the bytecode

2025-10-22T00:41:56.443319Z

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

2025-10-22T00:44:02.167949Z

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

mkvlr 2025-10-22T00:48:29.385799Z

TIL

2025-10-22T01:25:20.431709Z

Yes

mkvlr 2025-10-22T01:37:16.892169Z

alright, thanks for the explanation!

David Ko 2025-10-22T22:58:30.283089Z

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 🙏

phronmophobic 2025-10-22T23:32:54.519449Z

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.

🙏 1
phronmophobic 2025-10-22T23:33:25.598199Z

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.

phronmophobic 2025-10-22T23:34:48.582369Z

more generally, it seems like you might be interested in one of the pipeline functions in core.async

David Ko 2025-10-23T00:01:57.565459Z

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 itself

seancorfield 2025-10-23T00:12:59.976369Z

Those errors seem to have nothing to do with core.async -- is this code on GitHub where we can look at it?

🙏 1
seancorfield 2025-10-23T00:13:42.900229Z

The code you've posted references a lot of functions you don't show...

seancorfield 2025-10-23T00:14:24.239639Z

The complete stacktrace would help here...

seancorfield 2025-10-23T00:14:39.450399Z

*e in the REPL will show that.

seancorfield 2025-10-23T00:15:56.879709Z

Also, what is vehicle-type? You seem to pass v to process-url in the other function.

seancorfield 2025-10-23T00:17:43.922829Z

You mentioned ArityException but did not show that error -- that says one of your calls has the wrong number of arguments.

David Ko 2025-10-23T00:18:37.459819Z

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

David Ko 2025-10-23T00:19:21.188629Z

yea the ArityException seems to be gone, let me debug a with the *eand see if I can figure it out

David Ko 2025-10-23T00:21:38.652669Z

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

David Ko 2025-10-23T00:22:36.402569Z

again thank you @smith.adriane and @seancorfield for giving me some pointers, i’ll try again tomorrow 😅