Fork me on GitHub
#clojure
<
2020-10-18
>
fadrian02:10:12

I'm doing my first project using deps.edn. I've installed http://practicalli.github.io/clojure/clojure-tools/install/install-clojure.html, set up a simple project structure including deps.edn, and created a simple test program:

(ns parser.core
  (:require [clj-antlr :as a])
  (:gen-class))

(def p (a/parser "resources\\Cadr.g4"))
(p "caddr")

fadrian02:10:35

Here's the contents of my deps.edn:

{:paths ["src"]
 :deps {clj-antlr/clj-antlr {:mvn/version "0.2.6"}}}

fadrian02:10:01

When I run clojure -Xproject/find-deps, it seems to download a bunch of stuff and built a .cpcache directory, but when I try to run a repl after that, it complains because it can't find clj_antlr__init on the classpath. What magic incantation do I need to make clojure run a repl with my dependency loaded?

hiredman02:10:36

You need to know the correct namespace

hiredman02:10:51

The ns form deals in namespaces

hiredman02:10:45

The name you put in your deps.edn is the name of the library (technical the artifact and group ids in a macro repo)

hiredman02:10:34

The library is composed of some namespaces

hiredman02:10:59

You will have to look at the documentation for the library to see what the namespaces are

hiredman02:10:14

Then you can use those namespace names in the ns form

hiredman02:10:57

https://github.com/aphyr/clj-antlr the readme includes some calls to require that show the correct namespace name

hiredman02:10:21

And this kind of question really belongs in #beginners

fadrian02:10:32

I've actually been using the library for the past couple weeks in a couple of different lein-based projects. I just didn't remember to add the .core to the antlr requirement and since the error message didn't actually say anything about antlr.core (only mentioning the class corresponding to the clj-antlr namespace) and being somewhat unfamiliar with deps.edn-based projects, I figured something was going wrong with loading the dependency. Sorry to have disturbed.

sogaiu07:10:25

@noisesmith @schmee a bit of a late comment and may be it is known, but iiuc | is used for: https://github.com/clojure/clojure-clr/wiki/Specifying-types in clojure clr. i think i've seen @alexmiller warn people away from using it for symbol names in jvm clojure, but i don't have a reference for that.

Alex Miller (Clojure team)12:10:27

We are reserving it as a possible symbol delimiter so Iā€™d recommend not using it in symbols or keywords

sogaiu20:10:37

thanks for the clarification

Alex Miller (Clojure team)20:10:16

this is similar to Lisp |foo bar| would be a symbol with name foo bar

jjttjj16:10:39

I'm trying to set the clojure.javadoc/*feeling-lucky-url* to duckduckgo (the google url that's the default no longer seems to work for automatic redirects. The duckduckgo query should be prepended by a backslash to do the automatic redirect to the first result. I found this example here https://clojuredocs.org/clojure.java.javadoc/*feeling-lucky-url*

(binding [clojure.java.javadoc/*feeling-lucky-url* "\\"]
  (clojure.java.javadoc/javadoc your-class))
However this gives me the following error:
Illegal character in query at index 26: \...
I also tried using the url encoded backslash "%5C" is there a way to force the slash in the url here?

hiredman16:10:47

You may need \\\\

jjttjj16:10:29

gives the same error

andy.fingerhut16:10:15

What OS, JDK version, Clojure version are you using? I tried your first expression above replacing your-class with java.lang.Long and it worked. macOS 10.14.6, Oracle JDK 1.8.0_192, Clojure 1.10.1 in my case.

andy.fingerhut16:10:03

Also worked for me with macOS 10.14.6, AdoptOpenJDK 11.0.4, Clojure 1.10.1

jjttjj16:10:09

on openjdk 13 on windows

jjttjj16:10:37

Long will be in the default javadoc urls though and wouldn't trigger the feeling lucky search

jjttjj16:10:14

(that works for me to). it has to be an unrecognized class to trigger the search

andy.fingerhut16:10:07

Have an example class you tried that gave the error that I can test with?

Daniel Stephens16:10:00

@U064UGEUQ can you run (clojure.java.browse/browse-url "")?

jjttjj16:10:07

I'm using net.openhft.chronicle.queue.impl.single.SingleChronicleQueue but I believe it will have to be something on your classpath

andy.fingerhut16:10:59

I had never tried clojure.lang.PersistentVector as a class to that before, and was surprised to see it find a relevant page.

Daniel Stephens16:10:39

I just used

(binding [clojure.java.javadoc/*feeling-lucky-url* "\\"]
  (clojure.java.javadoc/javadoc (type (fn []))))
which worked for me

jjttjj16:10:56

does it automatically redirect you to the javadoc page? <ine just shows me search results, but I'm trying to get it to automatically redirect

jjttjj16:10:29

that works to load search results but without the redirect, which I believe is the origianlly intended behavior of the feeling lucky fallback

andy.fingerhut16:10:47

I also just tried with (type (fn [])) , and it took me to a duckduckgo page in my default Google Chrome browser, with the search box filled with \user$eval153$fn__154.html

šŸ‘ 3
jjttjj16:10:51

I think the problem might be that ultimately the string is being passed to URI to be browsed, and backslash is invalid but if I encode the backslash it tries to encode it again?

jjttjj16:10:25

yeah I get that too

jjttjj16:10:31

if you paste

in your webbrowser it takes you directly to the javadoc without search results

Daniel Stephens16:10:38

that works with the redirect for me from the repl with the original url you posted

Daniel Stephens16:10:46

I'm on ubuntu though

jjttjj16:10:18

ok hmmm maybe a windows thing, weird

jjttjj16:10:12

wait now it's working

šŸ˜… 3
jjttjj16:10:35

Ok this is what I was looking for

(binding [clojure.java.javadoc/*feeling-lucky-url*
          (URI. "")]
  (javadoc []))
this works now šŸ™‚ thanks!

Daniel Stephens16:10:37

ahh nice, preemtively make it a URI šŸ‘

Daniel Stephens19:10:47

java.lang.IllegalAccessException: Class clojure.lang.Reflector can not access a member of class org.apache.kafka.streams.state.internals.ValueAndTimestampDeserializer with modifiers "public final"
any idea why this happens, I'm just trying to get the value and it's public

Daniel Stephens19:10:32

ahh, dw, the class itself is package private

zhuxun220:10:21

Is (<!! (async/into [] ch)) the most idiomatic way to extract all values in a channel into a collection? I wasn't sure if I missed a collecting or dumping function