Fork me on GitHub
#clojure
<
2022-07-22
>
ag18:07:40

Can someone please tell me how #_ reader macro is implemented? Searching through http://github.com/clojure/clojure, I can't seem to find it.

borkdude18:07:03

@ag It's probably in LispReader.java.

p-himik18:07:22

It is, right in clojure.lang.LispReader.DiscardReader.

šŸ‘ 1
ag18:07:42

Thank you!

ag19:07:47

Oh wow. There's more stuff in there. http://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LispReader.java#L109-L120 what are CommentReader, EvalReader and UnreadableReader are for? Do we have things like #!, #= and #< ?

borkdude19:07:39

CommentReader is probably for ;, eval is indeed #=

ag19:07:49

But wait, it's not ; - dispatchMacros['!'] = new CommentReader();, see? It's gotta be #!

ag19:07:23

and how #= is used? I don't think I ever seen that

borkdude19:07:04

You're not going to need that

borkdude19:07:21

yes, comment reader can be used for both ; and #!

borkdude19:07:29

since it just ignores the rest of the line

ag19:07:36

ah, for shebangs, right

Sakib19:07:29

Is ( a symbol?

ghadi19:07:59

these are all symbols that sometimes are namespaced/symbols

ā¤ļø 2
dpsutton19:07:55

( is just a token for the lisp reader that is not reified anywhere Iā€™m assuming?

ghadi19:07:25

/ % + <!! also symbols

Drew Verlee22:07:27

I don't understand how the spec error can be so clear and yet i don't see the same thing. What i see is that the :refere-clojure is correctly using :exlude (first code block) but the spec error (second block) is very clear that it think it's an ":as" could the way i got to the library be not taking me to the real code? I just hovered over the import in my app and did a lsp-find-defination.

(ns clojure.core.async
  "Facilities for async programming and communication.

go blocks are dispatched over an internal thread pool, which
defaults to 8 threads. The size of this pool can be modified using
the Java system property `clojure.core.async.pool-size`."
  (:refer-clojure :exclude [reduce transduce into merge map take partition ;; <--------------- looks fine to me
                            partition-by bounded-count])
  (:require [clojure.core.async.impl.protocols :as impl]
            [clojure.core.async.impl.channels :as channels]
            [clojure.core.async.impl.buffers :as buffers]
            [clojure.core.async.impl.timers :as timers]
            [clojure.core.async.impl.dispatch :as dispatch]
            [clojure.core.async.impl.ioc-macros :as ioc]
            [clojure.core.async.impl.mutex :as mutex]
            [clojure.core.async.impl.concurrent :as conc]
            )
  (:import [java.util.concurrent.locks Lock]
           [java.util.concurrent Executors Executor ThreadLocalRandom]
           [java.util ArrayList]))
aused by: clojure.lang.ExceptionInfo: Call to clojure.core/refer-clojure did not conform to spec:
-- Spec failed --------------------

  (... ... ':as ...)
           ^^^^

should be one of: :exclude, :only, :rename

-- Spec failed --------------------

  (... ... (... :as) ...)
                ^^^

should be one of: :exclude, :only, :rename

-------------------------
Detected 2 errors
 {:clojure.spec.alpha/problems ({:path [:args :exclude :op :spec], :pred #{:exclude}, :val (quote :as), :via [], :in [2]} {:path [:args :exclude :op :quoted-spec :spec], :pred #{:exclude}, :val :as, :via [], :in [2 1]} {:path [:args :only :op :spec], :pred #{:only}, :val (quote :as), :via [], :in [2]} {:path [:args :only :op :quoted-spec :spec], :pred #{:only}, :val :as, :via [], :in [2 1]} {:path [:args :rename :op :spec], :pred #{:rename}, :val (quote :as), :via [], :in [2]} {:path [:args :rename :op :quoted-spec :spec], :pred #{:rename}, :val :as, :via [], :in [2 1]}), :clojure.spec.alpha/spec #object[clojure.spec.alpha$regex_spec_impl$reify__2436 0x1cb9ef52 "clojure.spec.alpha$regex_spec_impl$reify__2436@1cb9ef52"], :clojure.spec.alpha/value ((quote :exclude) (quote [reduce transduce into merge map take partition partition-by bounded-count]) (quote :as) (quote core)), :clojure.spec.alpha/args ((quote :exclude) (quote [reduce transduce into merge map take partition partition-by bounded-count]) (quote :as) (quote core))}

Drew Verlee22:07:04

I mean, i imagine the solution to my problem is to just update core async. But i'm going to have to do a lot of these updates and so i would like to be more sure of how to get feedback.

dpsutton22:07:06

seems like the value is (:refer-clojure :exclude [reduce transduce into merge map take partition partition-by bounded-count] :as core) . the problem the :as core bit

Drew Verlee22:07:49

interesting. so lsp did take me to another place. it was some cache.

Drew Verlee22:07:43

workshop/.cache/clojure.core.async.clj vs if i use cider-find-var i get core.async-0.2.395.jar:clojure/core/async.clj

dpsutton22:07:43

2f87bc7c7d10cb7b0baafc86e08489d58fa87424
Author:     Alex Miller <[email protected]>
AuthorDate: Tue Mar 14 12:17:56 2017 -0500
Commit:     Alex Miller <[email protected]>
CommitDate: Tue Mar 14 12:17:56 2017 -0500

Parent:     d17eb8a [maven-release-plugin] prepare for next development iteration
Contained:  master
Follows:    core.async-0.3.441 (2)
Precedes:   core.async-0.3.442 (2)

Fix bad :refer-clojure that fails with new refer-clojure spec (see CLJ-2062)

1 file changed, 1 insertion(+), 1 deletion(-)
src/main/clojure/clojure/core/async.clj | 2 +-

modified   src/main/clojure/clojure/core/async.clj
@@ -13,7 +13,7 @@ go blocks are dispatched over an internal thread pool, which
 defaults to 8 threads. The size of this pool can be modified using
 the Java system property `clojure.core.async.pool-size`."
   (:refer-clojure :exclude [reduce transduce into merge map take partition
-                            partition-by bounded-count] :as core)
+                            partition-by bounded-count])
   (:require [clojure.core.async.impl.protocols :as impl]
             [clojure.core.async.impl.channels :as channels]
             [clojure.core.async.impl.buffers :as buffers]

šŸ‘€ 1
Drew Verlee22:07:02

Thanks. ok. that all makes sense.

ericdallo23:07:41

I think it's a clojure-lsp bug indeed, there this is idea of appending the lib version on the path returned by clojure-lsp to avoid issues like that... for now killing the buffer should fix the cache issue

šŸ‘€ 1