This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-02-25
Channels
- # announcements (6)
- # asami (1)
- # babashka (80)
- # beginners (89)
- # bitcoin (1)
- # calva (30)
- # cider (33)
- # clj-kondo (1)
- # cljsrn (45)
- # clojars (5)
- # clojure (60)
- # clojure-australia (1)
- # clojure-dev (9)
- # clojure-europe (133)
- # clojure-italy (7)
- # clojure-nl (6)
- # clojure-uk (44)
- # clojurescript (11)
- # conjure (1)
- # data-oriented-programming (2)
- # datahike (13)
- # datascript (4)
- # datomic (19)
- # deps-new (29)
- # depstar (5)
- # duct (39)
- # fulcro (8)
- # girouette (1)
- # helix (10)
- # honeysql (17)
- # jobs (5)
- # jobs-discuss (2)
- # leiningen (6)
- # lsp (51)
- # malli (60)
- # meander (37)
- # membrane (8)
- # off-topic (31)
- # overtone (3)
- # pathom (36)
- # re-frame (8)
- # reagent (30)
- # remote-jobs (2)
- # sci (1)
- # sql (32)
- # startup-in-a-month (3)
- # testing (3)
- # tools-deps (7)
- # xtdb (7)
Has anyone installed Clojure from the guix package manager (i.e. guix install clojure). When I do that on ubuntu and run clojure
, it gives me a repl. But it seems to ignore deps.edn files in the current directory. Anyone have any clues what could cause that kind of behaviour?
Clojure didn't have an official launcher like the tools.deps scripts have become for a long time, so many packagers in linux distributions included their own launcher scripts
https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/packages/clojure.scm#n125 nonsense
Thanks @hiredman, It was fine with the official installer scripts. But guix has nice advantages, so it would be nice to see something working. Thanks for the pointer to the repo, now that I know where it is maybe at some future time I'll have a go at a patch to make guix do something more similar to the installer script.
given that the only "global" install required for clojure is a jvm, and everything else is determined by per-project config and cached, I don't think guix helps much with clojure
and of course you can use deps.edn clojure with a jvm installed by guix
I’m using re-seq to get all the sequences that match a regex in clojure like so:
(re-seq #"(.*)\&(.*)" "((a & b) & c)")
And I’m getting the following result:
(["(a&b)&c" "(a&b)" "c"])
Whereas I expect the sequence to contain all such regex matches like so:
(["(a&b)&c" "(a&b)" "c"] ["(a&b)&c" "(a" "b)&c"])
How to fix this and what am I doing wrong?Is there a way to get all regex matches?
that is not the result I'm getting
(re-seq #"(.*)\&(.*)" "((a & b) & c)")
=> (["((a & b) & c)" "((a & b) " " c)"])
(.*)\&(.*)
tantalizing regex
@ghadi I have a (remove-whitespace …) wrapped around the string
(defn remove-whitespace [string] (str/replace string #“[ ]*” “”))
whereas
(re-seq #"(.*?)\&(.*?)" "(a & b) & c")
> gives
(["((a&" "((a" ""] ["b)&" "b)" ""])
is there a way to get all recursive matches?
I think regexes are a bad tool for this job - you want a parser
Also instaparse is awesome once you get the hang of it. Well worth taking a few moments to learn.
does anyone know why this isn't possible:
(let [math-class (resolve 'Math)]
(. math-class floor 5.677))
I'm trying to get a java class and then call a static method on it.maybe I'm going about this incorrectly. I want to specify a java class in an edn file and then load that at run time and call static methods on that class
math-class is not going to get eval'ed there - the . special form expects a literal class name
you really need to use Java reflection if you want to do this dynamically
or dynamic invocation with method handles
for reflection - Class/forName, then .getMethod(s), then invoke
for dynamic invoke - start from MethodHandles/lookup, then .findStatic with a MethodType/methodType
or you could build a Clojure expression and eval it :)
(eval (list '. 'java.lang.Math 'floor 1.2))
I'm not sure how much of a distraction they really are, but maybe PRs on Clojure and the contrib libs could be auto-closed with GitHub Actions? Something like
---
name: Close pull requests
on:
- pull_request
jobs:
comment:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
await github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Hi, this project does not accept pull requests (please see for more info on contribution process).'
})
await github.issues.update({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
state: 'closed'
})
i asked a variation of this question in #testing, but seemed broad enough to warrant discussion: i have defined a bunch of helper functions for use in my test suite. They do validation before passing code into the game engine (the same validation the game's UI does). When the validation fails, the line number in the error points to the helper function instead of the line in the test, so I converted the helper functions to macros so that the failure correctly points to the test's file and line.
However, this makes the compilation time of my test suite balloon significantly. switching the two primary helper functions to macros makes my total test suite go from 40 seconds to 70 seconds
i realize this is somewhat the nature of macros, but it still seems pretty intense. is there any way to get both correct line numbers and short test compilation times?
Yes, when the verification fails capture a stacktrace, them walk up the trace to your test code, and report that line number
I don't understand why the scenario described above is slower? Macros don't appear to be a slow mechanism (you can (time (macroexpand ...))
to verify this claim), and macro-emitted code should be fast as well (for one thing it elides would-be function calls)
I do have experience assessing a certain slowness in the clojure compiler itself (and have asked about it here, gathering the fact that it intentionally emits simple code that is easy for the JVM to optimize). Not sure how macros play a role (if at all) in the equation
this is really visible with complex macros, like if you use the go macro in core.async
i'm surprised by the claim that compilation of a namespace goes from 40 to 70 seconds. that seems incredibly high to me
Y'all got to chatting about this after I got off the computer for the day! One of the macros is used 1500 times and the other over 3000, lol
yes 30s seems a disproportionate cost for changing a defn to a defmacro. I'd assume from the OP that the defn was doing something fairly straightforward
it is, but if the macros contain calls to other macros you can easily inflate things
It could depend on how often the would-be defn "bar" is invoked from other parts of the program. If bar is invoked 50 times, then when bar is a defn, the macro-expansions inside of it occur one time when loading the code. When bar is a defmacro, then bar and everything inside of it will be expanded 50 times when loading the code.
there was a performance regression in some jvm version, maybe 2 years ago by now? where code loaded while running static initializers (java feature) wouldn't get jit compiled, and clojure loads user.clj via a static init, so if you had a user.clj, and that user.clj loaded core.async, the macro expansion would run significantly slower
https://cl4es.github.io/2019/02/21/Cljinit-Woes.html some background on it
Fixed in Clojure 1.10.1
Y'all got to chatting about this after I got off the computer for the day! One of the macros is used 1500 times and the other over 3000, lol