clojure

New to Clojure? Try the #beginners channel. Official docs: https://clojure.org/ Searchable message archives: https://clojurians-log.clojureverse.org/
2020-10-18T02:13:12.289Z

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

2020-10-18T02:14:35.289900Z

Here's the contents of my deps.edn:

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

2020-10-18T02:18:01.293100Z

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?

2020-10-18T02:27:36.293600Z

You need to know the correct namespace

2020-10-18T02:27:51.294300Z

The ns form deals in namespaces

2020-10-18T02:28:45.295800Z

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

2020-10-18T02:29:34.297200Z

The library is composed of some namespaces

2020-10-18T02:29:59.298Z

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

2020-10-18T02:30:14.298700Z

Then you can use those namespace names in the ns form

2020-10-18T02:31:57.301700Z

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

2020-10-18T02:33:21.304300Z

And this kind of question really belongs in #beginners

2020-10-18T02:47:32.310200Z

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.

2020-10-18T07:33:25.311900Z

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

alexmiller 2020-10-18T12:48:27.313500Z

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

2020-10-18T16:29:39.317100Z

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* "<https://duckduckgo.com/?q=>\\"]
  (clojure.java.javadoc/javadoc your-class))
However this gives me the following error:
Illegal character in query at index 26: <https://duckduckgo.com/?q=>\...
I also tried using the url encoded backslash "%5C" is there a way to force the slash in the url here?

2020-10-18T16:31:47.317400Z

You may need \\\\

2020-10-18T16:32:29.317600Z

gives the same error

2020-10-18T16:40:15.317800Z

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.

2020-10-18T16:42:03.318Z

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

2020-10-18T16:43:09.318200Z

on openjdk 13 on windows

2020-10-18T16:44:37.318500Z

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

2020-10-18T16:45:14.318700Z

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

2020-10-18T16:46:07.318900Z

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

Daniel Stephens 2020-10-18T16:47:00.319100Z

@jjttjj can you run (clojure.java.browse/browse-url "<http://google.com>")?

2020-10-18T16:47:07.319300Z

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

2020-10-18T16:47:37.319600Z

@dstephens yes

2020-10-18T16:47:59.319800Z

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

Daniel Stephens 2020-10-18T16:48:39.320Z

I just used

(binding [clojure.java.javadoc/*feeling-lucky-url* "<https://duckduckgo.com/?q=>\\"]
  (clojure.java.javadoc/javadoc (type (fn []))))
which worked for me

2020-10-18T16:48:56.320200Z

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

2020-10-18T16:49:29.320400Z

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

2020-10-18T16:50:47.320700Z

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

šŸ‘ 1
2020-10-18T16:50:51.320900Z

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?

2020-10-18T16:52:25.321200Z

yeah I get that too

2020-10-18T16:53:31.321500Z

if you paste

<https://duckduckgo.com/?q=%5Cclojure/lang/PersistentVector.html>
in your webbrowser it takes you directly to the javadoc without search results

Daniel Stephens 2020-10-18T16:54:38.321700Z

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

Daniel Stephens 2020-10-18T16:54:46.321900Z

I'm on ubuntu though

2020-10-18T16:55:18.322100Z

ok hmmm maybe a windows thing, weird

2020-10-18T16:56:12.322300Z

wait now it's working

šŸ˜… 1
2020-10-18T16:56:35.322600Z

Ok this is what I was looking for

(binding [clojure.java.javadoc/*feeling-lucky-url*
          (URI. "<https://duckduckgo.com/?q=%5C>")]
  (javadoc []))
this works now šŸ™‚ thanks!

Daniel Stephens 2020-10-18T16:57:37.322800Z

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

Daniel Stephens 2020-10-18T19:55:47.324Z

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 Stephens 2020-10-18T19:57:32.324300Z

ahh, dw, the class itself is package private

2020-10-18T20:32:37.324400Z

thanks for the clarification

zhuxun2 2020-10-18T20:38:21.326600Z

Is (&lt;!! (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

alexmiller 2020-10-18T20:53:16.327100Z

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