This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-08-28
Channels
- # announcements (2)
- # babashka (36)
- # beginners (29)
- # bristol-clojurians (2)
- # calva (3)
- # cider (102)
- # circleci (7)
- # clj-kondo (5)
- # cljs-dev (7)
- # clojure (117)
- # clojure-europe (23)
- # clojure-korea (1)
- # clojure-nl (1)
- # clojure-spec (15)
- # clojure-uk (47)
- # clojurescript (43)
- # code-reviews (1)
- # community-development (1)
- # conjure (32)
- # cursive (1)
- # datalog (15)
- # datomic (14)
- # emacs (18)
- # fulcro (9)
- # helix (23)
- # jackdaw (1)
- # jobs-discuss (10)
- # meander (8)
- # membrane (57)
- # off-topic (4)
- # portal (2)
- # re-frame (22)
- # reagent (1)
- # reitit (9)
- # reveal (3)
- # rewrite-clj (14)
- # shadow-cljs (22)
- # spacemacs (27)
- # sql (34)
- # testing (6)
- # tools-deps (40)
- # vim (5)
- # vrac (15)
- # xtdb (2)
@dpsutton It's documented somewhere because I was just reading about it the other day. I just can't remember where.
Hmm, it's documented in Clojure, The Essential Reference and the section about fn*
was contributed by @bronsa so maybe he knows where it officially documented?
It has a footnote linking to https://groups.google.com/g/clojure/c/FLrtjyYJdRU?pli=1 and says Rich discusses the locals clearing aspect of fn*
there.
(I don't see fn*
mentioned there, only the general concept of locals clearing)
there's a comment talking about issue 232 and that's the commit where it shows up but i can't follow the logic of the commit. https://clojure.atlassian.net/browse/CLJ-232
A blast from the past, that ticket is littered with former co-workers. The issue there is delays used to try and run again if derefed again and the first time threw an exception
And you would get npes because the once fn would clear any locals so they would be nil the second time the fn was run
Because delay
wraps the ^:once fn*
thing...
(defmacro delay
...
{:added "1.0"}
[& body]
(list 'new 'clojure.lang.Delay (list* `^{:once true} fn* [] body)))
Interesting bit of history in that ticket.
Testing against 1.10, it seems it all got fixed even tho' there's no indication of what the resolution was in that ticket?
I didn't realize delay
used the :once fn*
thing until just now.
Yeah, the patch looks like it does what it says on the commit message https://github.com/clojure/clojure/commit/93fecbd825c26e2570f8449cd64d0df0cc520c1d it disables the code that would cleared closed over locals at the end of a function of possible, and adds that functionality to the system for clearing regular locals, which already correctly handled try/finally which was the source of the bug
Ah, I missed that link (I'm not signed into JIRA on this machine).
Oh, that's what Rich links in the first comment?
CLJ-232 is the jira id, but this was part of a bulk import from the older Assembla issue tracker, so had a different id originally
(which I guess was the last comment before the importer messed up the timeline?)
How do I re-throw an exception preserving the stacktrace while adding an informative message to the top?
(try (read-raw fname)
(catch Exception e
(throw (ex-info
(str "error parsing file: \n "
fname "\n " (ex-message e))
(into {} (ex-data e))))))
tried something like this, but it appears as the only item in the stacktraceyou can use .getStackTrace
` and .setStackTrace
@dpsutton @seancorfield @hiredman afaik, there is no official doc about ^:once (possibly intentionally to not encourage its use outside of core). generally most things should build upon the core stuff like lazy-seq instead
its things like this: https://github.com/clojure/core.async/blob/master/src/main/clojure/clojure/core/async.clj#L461
(dispatch/run
(^:once fn* []
(let [~@(mapcat (fn [[l sym]] [sym `(^:once fn* [] ~(vary-meta l dissoc :tag))]) crossing-env)
f# ~(ioc/state-machine `(do ~@body) 1 [crossing-env &env] ioc/async-custom-terminators)
state# (-> (f#)
(ioc/aset-all! ioc/USER-START-IDX c#
ioc/BINDINGS-IDX captured-bindings#))]
(ioc/run-state-machine-wrapped state#))))
as core.async go loops basically replicate the clojure analyzer, they need to dive into this level of detail, but generally that's not something most user-level code should be doing
but as summarized above - it's a user-level hint to the compiler to tell it this is used once and can then be cleared
What’s an easy way to split a byte array in two with a given delimiter (ala (clojure.string/split s re 2)
)?
Well, I’d need to find the delimiter first. Also, the byte array is huge and I need this to be performant.
I don’t want to make any unnecessary copies and I don’t want to iterate over the entire array
also, I want two byte arrays at the end
You should need to work on Clojure Data Types
and why they are simply amazing for Functional Programming.
Sometimes you still need to drop down to raw byte arrays
I think, if your requirements are beyond the performance Clojure gave, you should think about technologies like C++ or D or V.
Or just find a Java solution and use it as is or translate it to Clojure, either directly with interop or by using Clojure alternatives to what Java uses.
Yeah I’m gonna go with that. I was just hoping there’d be a more straightforward solution :)
I copied a project from one machine to another, and I'm having this weird problem fetching javase when using leinengen. Deleting ~/.m2
didn't fix it and I'm a bit stumped after googling for a solution. Any clues? Using Java 11 and clojure 1.10.1 for now.
Could not find artifact com.github.kenglxn.qrgen:javase:jar:2.6.0 in central ( )
Could not find artifact com.github.kenglxn.qrgen:javase:jar:2.6.0 in clojars ( )
Could not find artifact com.github.kenglxn.qrgen:javase:jar:2.6.0 in sonatype-oss-public ( )
Could not transfer artifact com.github.kenglxn.qrgen:javase:jar:2.6.0 from/to jitpack (): NullPointerException
Could not find artifact com.github.kenglxn.qrgen:javase:jar:2.6.0 in sonatype ()
Could not find artifact com.github.kenglxn.qrgen:javase:jar:2.6.0 in sonatype-snapshots ()
Failed to read artifact descriptor for com.github.kenglxn.qrgen:javase:jar:2.6.0
This could be due to a typo in :dependencies, file system permissions, or network issues.
If you are behind a proxy, try setting the 'http_proxy' environment variable.
Are you sure that package exists in maven central, clojars or other places that lein is looking from
It is there, only the qrgen
part is spelled as QRGen
: https://mvnrepository.com/artifact/com.github.kenglxn.QRGen/javase/2.6.0
http://search.maven.org says that 2.0 is the lastest version https://search.maven.org/artifact/net.glxn.qrgen/javase/2.0/jar
http://mvnrepository.com lists also packages that are not part of maven central.
Note: this artifact is located at https://mvnrepository.com/repos/mulesoft-public repository (https://repository.mulesoft.org/nexus/content/repositories/public/) (note on https://mvnrepository.com/artifact/com.github.kenglxn.QRGen/javase/2.6.0 page)
try adding the mulesoft repo to :repositories
in your project.clj
. See https://github.com/technomancy/leiningen/blob/stable/sample.project.clj#L104
And the repo of QRGen itself says: "As of 2.1.0 QRGen is available from http://jitpack.io. QRGen is no longer deployed to maven central"
Notes: 1. I didn't have to add extra repos before, but perhaps I was making due with older compilation and m2 repo contents.
2. Adding http://jitpack.io to the :repositories doesn't seem to help, in fact, interestingly, I now get TWO NullPointerException entries for http://jitpack.io: Could not transfer artifact com.github.kenglxn.qrgen:javase:jar:2.6.0 from/to
Following the jitpack instructions on this page https://jitpack.io/#kenglxn/QRGen just gave me additional errors trying to load the Tag dependency.
(defproject foo "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url ""
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
:url " "}
:dependencies [[org.clojure/clojure "1.10.0"]
[com.github.kenglxn.QRGen/javase "2.6.0"]]
:repositories [["jitpack" ""]]
:repl-options {:init-ns foo.core})
Yeah, no such luck fo rme. http://jitpack.io (and only http://jitpack.io) is failure. My project lists only these dependencies:
[[org.clojure/clojure "1.10.1"]
[one-time "0.7.0"]
[com.github.kenglxn.QRGen/javase "2.6.0"]
```(trying your expcicit javase, otherwise it isn't explicitly in my depdenencies, and I have no idea where it's coming from)
lein new app
and this profile also fail:
(defproject foo "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url ""
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
:url " "}
:repositories [["jitpack" ""]]
:dependencies [[org.clojure/clojure "1.10.1"]
[com.github.kenglxn.QRGen/javase "2.6.0"]]
:main ^:skip-aot foo.core
:target-path "target/%s"
:profiles {:uberjar {:aot :all
:jvm-opts ["-Dclojure.compiler.direct-linking=true"]}})
Fix/workaround: this repository entry works: ["Mulesoft" "https://repository.mulesoft.org/nexus/content/repositories/public/"]
Debian Clojure Packaging Bof is happening right now https://debconf20.debconf.org/schedule/venue/1/ https://pad.online.debconf.org/p/33-clojure-packaging-team-bof
birds of a feather? don't know the origin, but ietf has had such things: https://www.ietf.org/how/bofs/
yes, BoF is Birds of a Feather. It's a type of meeting https://en.wikipedia.org/wiki/Internet_Engineering_Task_Force#Organization
the meeting was about packaging clojure for Debian and the issues about that. Debian is pretty particular in the sense that all Debian packages should be buildable without internet access. You should need only depend on other packages in Debian.
one of the issues with packaging clojure for Debian is around reproducability. Reproducability is one of the goals of Debian https://wiki.debian.org/ReproducibleBuilds .
one of the big issues related to packaging is that clojure is not reproducible https://tests.reproducible-builds.org/debian/rb-pkg/unstable/amd64/clojure.html Some context: https://reproducible-builds.org/
I am not familiar with the details here, but is there any software written in Java, distributed as JAR files, that is considered reproducible?
It seems that the reason for non-reproducibility in the sense that caused that issue is purely due to timestamps in JAR files.
We had that problem in my packaging library for a while. But someone just set clj files to the minimum date, and class files to the maximum.
well, it's been an ongoing effort for a couple of years now. There is some work and guide for maven: https://maven.apache.org/guides/mini/guide-reproducible-builds.html https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=74682318 For gradle: https://docs.gradle.org/current/userguide/working_with_files.html#sec:reproducible_archives And an article I found with a quick search https://dzone.com/articles/reproducible-builds-in-java
the idea is that from the source you get the same binary regardless of which machine you build it on.
I remember a talk about debugging by def
ing vars inline and iterating at the REPL, but I can't find it by Googling. There may have been a library and/or editor integration to assist in creating the vars. Anyone recall the name?
@robert.mather.rmm ScopeCapture I think? I just have a hotkey bound to eval (def <selection>)
so that I can highlight a binding in a let
and turn it into a global for debugging.
@seancorfield That's the one, thanks!
I prefer not to need to add any code while I'm working, and I use REBL, so I can create a def
from any value sent to the REBL and between that and my hotkey to turn let
bindings into def
that's pretty much all I ever need.
Heh, my Rich Comment Forms are all over my code! Since I work with Atom/Chlorine, the REPL panel there is readonly so you're never tempted to type into it -- so you use RCFs instead.
I've written a test.check test, but I don't want to use it with clojure.test, but instead separately with it's own params. Is there a pre-written script or main I can use?
(I want to avoid clojure.test, because I don't want to run it with the tests all the time, as it may fail unreliably)
Ah, clojure.test.generative.runner :) It would seem that test.generative is not the same as test.check. But this must be the split itself in clj.
I am using Datomic Cloud and am trying to compile my code before deployment -- to catch any errors without incurring AWS costs. I am using @seancorfield’s excellent depstar
but I don't have a -main
since I am deploying Ions. Can anyone advise me how to do the compilation? thanks!
@UGNMGFJG3 Do Ions not have a standard entry point?
(I am not familiar with them)
Yeah, but how does it know what to call in your Ion code?
The general answer here is:
1. create a classes
folder
2. add it to your :paths
in deps.edn
3. run clojure -e "(compile,'your.namespace)"
to compile stuff
4. run depstar
so it will JAR up the source and the classes
Or if you only care about putting the source in the JAR, but want to do the compile as a sanity check, add a :compile
alias that has :main-opts ["-e" "(compile,'your.namespace)"]
and then clojure -A:compile
and don't both putting "classes"
in your :paths
-- you still need the folder for compile
to compile into.
Thanks @seancorfield! I appreciate your help!
I think the way to do that is to still use clojure.test, but have a separate test suite, in another source directory
@hiredman that's what I initially reached for, but wanting to run the generative tests by themselves when otherwise running all the tests (e.g. Cider-run-tests) brings it back to a problem.
does it? surely you have someway to take two commands and turn them in to one command?
@dominicm What about test selectors?
Both lein test
and Cognitect's test-runner
have ways to select tests based on metadata...
I talk about that for the clojure.test
-compatible version of Expectations: https://cljdoc.org/d/expectations/clojure-test/1.2.1/doc/fixtures-focused-execution#focused-test-execution
(it's about the core clojure.test
/ test runner approach, nothing specific to Expectations)