This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-09-24
Channels
- # announcements (2)
- # beginners (131)
- # calva (4)
- # cider (29)
- # cljs-dev (18)
- # cljsrn (8)
- # clojure (61)
- # clojure-czech (1)
- # clojure-europe (5)
- # clojure-italy (14)
- # clojure-nl (6)
- # clojure-switzerland (2)
- # clojure-uk (125)
- # clojuredesign-podcast (10)
- # clojurescript (25)
- # clojutre (15)
- # clr (4)
- # code-reviews (4)
- # data-science (1)
- # emacs (1)
- # events (2)
- # fulcro (12)
- # graalvm (4)
- # jobs (2)
- # keechma (1)
- # off-topic (1)
- # pathom (18)
- # re-frame (3)
- # reagent (7)
- # shadow-cljs (106)
- # spacemacs (33)
- # sql (12)
- # xtdb (5)
You could set system properties (but not env vars)
Hi Experts, How would you represent a ranked collection in clojure? Like that of ranked users on some number of points?
There are various options but if your data size is big, and care about performance, you probably need to consider with peculiarities in your use case (read/write patterns)
if you already had it in your stack, a sorted set in Redis is another good way to do this.
Thanks all, the data-set is not too big. Likely fewer than 10k entries
How can I get the index (rank/sort position) of an map matching on a specific key after i do (sort-by) ? tanks
Some dependency in my webapp is causing a java app to appear on my dock (macOS). Is there a clever way to figure out which dependency is doing that? (Excluding obvious things like partitioning the requires)
Hi all, from what I've read a lot of effort went into improving error reporting in Clojure 1.10. However, I just updated a somewhat minimal project and the error messages seem less helpful than they were in 1.9. For example: In 1.9:
clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: No such namespace: a, compiling:(my/example/ns.cljc:16:16)
In 1.10:
clojure.lang.Compiler$CompilerException: Syntax error compiling at (my/example/ns.cljc:16:16).
{:clojure.error/phase :compile-syntax-check, :clojure.error/line 16, :clojure.error/column 16,
:clojure.error/source "my/example/ns.cljc"}
The error messages no longer tells you what heuristic was broken, just that it's a general syntax error and where to find it. I'm wondering if there may be some configuration or dependency that I might be missing?actually, that example is exactly what i would point to - name errors are not as easy to recognize.
in this case it's not a missing dep, it's invalid syntax, newer clojure versions are more strict about syntax that older versions let slide
oh - never mind, that wasn't your point
@zalky What REPL/tooling are you using when you see that? Not all tooling has caught up with the underlying changes in 1.10/1.10.1 so some tooling now shows worse errors.
@U04V70XH6, I thought it might be something related to that. I'm using boot 2.8.3, and nrepl 0.6.0.
what do you see if you evaluate *e
after getting that error in a repl (eg. require / :reload or load-file)?
Ah, I think you may be right! I believe the discrepancy is due to my setup, which involves connecting my cider repl to a remote nrepl server and a running watch task that recompiles all my clojure code on change. When the watch task tries to reload the code, it seems like it only emmit the partial error. If I try to reload the namespace from the cider repl, the full error shows up, which includes both the syntax check, and the no such namespace error. So I guess I need to figure out what is responsible for emitting the error from the watch task.
I wouldn't be surprised if the tool had a new version that behaved better with newer clojure versions
I doubt that combination has been updated to leverage the new error triage machinery. 2.8.3 is the latest stable release of Boot so I think you're just out of luck there.
oh, boot limits the cider / nrepl layer? never mind, I misread, cider wasn't in charge of the watcher
In order to take advantage of the error reporting improvements in 1.10(.1), tooling needs to be updated to conditionally use the new triage function introduced there.
clj
/ clojure
does this (of course) and I suspect Leiningen may have been updated (maybe?). I would expect the latest CIDER to do it -- that team is very active -- but Boot's last release was back in April and although 1.10 came out in December last year, 1.10.1 didn't appear until June. So I suspect the Boot team didn't really have the new handling on their radar that soon after 1.10...?
I don’t know what boot is exactly doing in this case so hard for me to say. But the Error Reporting section of https://clojure.org/reference/repl_and_main covers the various things now available to use.
So, after some digging, the tool in question (danielsz/system) uses clojure.stacktrace/print-throwable
to emit the error. The error being emitted does in fact have the full error with all the relevant information, but it seems that clojure.stacktrace/print-throwable
prints only the first part of the error (in the :via
property). Is there some better way to produce a printable string of the error?
it looks like that error reporter is showing the ex-info data but not the error message
deps.edn
question: I'm using a repo that has three artifacts (https://github.com/roman01la/uix), core
, dom
and rn
, each with their own deps.edn. How can I use tools.deps with git resolution to make this work?
Writing a grammar in instaparse I get stuck at the following problem:
(let [expr "> abc :foo bar baz :and 300"
parser (insta/parser
"expr = token (<whitespace> token)*
<token> = cmd | search-phrase | key-arg-pair
cmd = '>' | 'cb' | '>cb'
search-phrase = not-cmd-and-words-or-numbers
key-arg-pair = keyword <whitespace> arg
<keyword> = #':[a-zA-Z0-9]+'
<arg> = (keyword | not-cmd-and-words-or-numbers)
(* not cmd and then any words and numbers *)
<not-cmd-and-words-or-numbers> = !cmd words-numbers
words-numbers = word | number (<whitespace> words-numbers)*
<word> = #'[a-zA-Z]+'
<number> = #'[0-9]+'
whitespace = #'\\s+'
")]
(clojure.test/is
(=
[:expr
[:cmd ">"]
[:search-phrase [:words-numbers "abc"]]
[:key-arg-pair ":foo" [:words-numbers "bar" "baz"]]
[:key-arg-pair ":and" [:words-numbers "300"]]]
(parser expr))))
output:
FAIL in () (command_bar.cljc:102)
expected: (= [:expr [:cmd ">"] [:search-phrase [:words-numbers "abc"]] [:key-arg-pair ":foo" [:words-numbers "bar" "baz"]] [:key-arg-pair ":and" [:words-numbers "300"]]] (parser expr))
actual: (not (= [:expr [:cmd ">"] [:search-phrase [:words-numbers "abc"]] [:key-arg-pair ":foo" [:words-numbers "bar" "baz"]] [:key-arg-pair ":and" [:words-numbers "300"]]] [:expr [:cmd ">"] [:search-phrase [:words-numbers "abc"]] [:key-arg-pair ":foo" [:words-numbers "bar"]] [:search-phrase [:words-numbers "baz"]] [:key-arg-pair ":and" [:words-numbers "300"]]]))
arg
is supposed to match multiple words through the underlying not-cmd-and-words-or-numbers
. Instead search-phrase
takes precedence.
instaparse doesn’t guarantee precedence unless you use an ordered choice operator (`/` as opposed to |
), or a negative lookahead (`!`) to enforce that certain rules are a “last resort”
wisdom from the source! thanks @aengelberg. still I'm not able to force precedence, even with the ordered operator
ah, looking more closely at your grammar I can see why that wouldn’t work
@denik it seems like the DSL you’re implementing has the property that once you start adding keyword arguments, everything from that point forward should be part of a keyword argument pair (not a search phrase)
but you aren’t encoding that into the grammar
@aengelberg exactly right. isn't this part encoding it?
key-arg-pair = keyword <whitespace> arg
<keyword> = #':[a-zA-Z0-9]+'
<arg> = (keyword | not-cmd-and-words-or-numbers)
that part is accurately defining what keyword arguments look like, but when you write :kw arg1 arg2
, arg2
could legitimately either be the second argument or a new search phrase
so it isn’t ruling out the possibility of more search phrases after your keywords
I think you need to re-organize the grammar top-down. at a high level it should look something like this:
expr = cmd search-phrase+ key-arg-pair+
I’m making some assumptions there, and also missing the whitespace, but that might be a starting point
ok thanks @aengelberg any way to match search-phrase
only once?
expr = cmd <whitespace> search-phrase <whitespace> key-arg-pair*
i might not have gotten the bits and pieces exactly right, but the idea is to tell instaparse “all the search terms go first, then all the keyword arguments”