This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-03-27
Channels
- # announcements (8)
- # babashka (7)
- # beginners (24)
- # biff (5)
- # calva (17)
- # cider (1)
- # clj-kondo (4)
- # clojure (61)
- # clojure-europe (5)
- # clojure-norway (19)
- # clojurescript (17)
- # conjure (1)
- # core-typed (14)
- # cursive (9)
- # datomic (7)
- # events (2)
- # figwheel (2)
- # helix (1)
- # honeysql (4)
- # jobs (3)
- # lsp (3)
- # malli (2)
- # nrepl (13)
- # off-topic (9)
- # pathom (6)
- # pedestal (3)
- # polylith (3)
- # portal (7)
- # reagent (4)
- # reitit (2)
- # shadow-cljs (49)
- # tools-deps (8)
- # vim (3)
So I wanna make a desktop app, but I don't really wanna use something java based as wayland support is non-existent. Intellij idea won't work on sway. How difficult would it be to have Clojure somehow interface with GTK?
or if you want a clojure-based wrapper, you could use coffi https://github.com/IGJoshua/coffi
Probably too young at this point, but I am looking at https://github.com/HumbleUI for this type of thing.
Glfw claims to support wayland. The various libraries that use glfw might be an option: • https://www.lwjgl.org/ • https://github.com/JetBrains/skija/ • https://github.com/phronmophobic/membrane (my library) For better or worse, it's a very different beast than GTK. There's also the cljs route with something like electron.
The only reason I ask, is because I'm trying to avoid Electron. Neutralino seemed promising, but unfortunately I can't get passed a simple bug within it.
I've also used cljfx, and seesaw with some success, but that was on MacOS. I'm also concerned about wayland support for two reasons. 1. It's what I live in on a daily basis 2. It has great HiDPI and MultiDPI support, unlike X will ever have.
oooh, skija seems pretty cool
Is there a binary version of .edn? What I'm looking for is more performance and less disk space usage, but keep it schema-free. What are you using for that? As a compromise I thought I'll use .edn but ZIP it before/after, but I guess there is something more high tech than that 🙂
Is there some good resource to learn about the new stuff in clojure 1.11 ? I mean something more elaborate than the official release announcement
I remember there was some -slim jar distribution in which clojure was not directly linked / AOT-ed, but I don't see that on mvn. Tangentially related, is there also a jar that includes the Java sources and how could one discover these alternative jars?
there is a "slim" classifier out there
you'd use it with org.clojure/clojure$slim {:mvn/version "1.11.0"}
for example
(you can see all the artifacts at https://repo1.maven.org/maven2/org/clojure/clojure/1.11.0/ for example)
Are classifiers a maven thing? It’s weird that you cannot see these at all on http://mvnrepository.com.
https://maven.apache.org/plugins/maven-deploy-plugin/examples/deploying-with-classifiers.html
classifiers are a maven thing, yes
classifier artifacts are weird in that they all share the same pom. they were originally intended for "variants" of an artifact (specific to a jdk or architecture) but are also somewhat abused for more metadata like things (source, javadoc)
I don't think the designers of Maven understood the problem space enough at the time of design and things in this area are complected
Thanks! Ah, so there is a -sources classifier. But would that also contain the compiled classes, or is that an extra dep to pull in?
sources is not intended to be a runnable thing, it's original intent was for providing Java source for Java artifacts
if I understand what you want, it's the slim classifier, which is intended to be non-AOT Clojure artifact
well, I was looking actually for $sources, since Eric and I are adding Java class navigation to kondo/lsp. So if people would include that extra artifact, they would be able to navigate to the source (rather than decompiling the .class)
ah, so then you do probably want sources, although I don't recall if that has the Java source in it
Confirmed:
$ clojure -M:clj-kondo/dev --lint $(clojure -Spath -Sdeps '{:deps {org.clojure/clojure$sources {:mvn/version "1.11.0"}}}') --config '{:output {:format :edn :analysis {:java-class-definitions true}}}' | jet -f '(fn [out] (take 10 (filter #(str/ends-with? (:uri %) ".java") (:java-class-definitions (:analysis out)))))' --pretty
({:class "clojure.asm.SymbolTable",
:uri "jar:file:file:/Users/borkdude/.m2/repository/org/clojure/clojure/1.11.0/clojure-1.11.0-sources.jar!/clojure/asm/SymbolTable.java",
:filename "/Users/borkdude/.m2/repository/org/clojure/clojure/1.11.0/clojure-1.11.0-sources.jar:clojure/asm/SymbolTable.java"}
{:class "clojure.asm.Label",
:uri "jar:file:file:/Users/borkdude/.m2/repository/org/clojure/clojure/1.11.0/clojure-1.11.0-sources.jar!/clojure/asm/Label.java",
:filename "/Users/borkdude/.m2/repository/org/clojure/clojure/1.11.0/clojure-1.11.0-sources.jar:clojure/asm/Label.java"}
{:class "clojure.asm.Attribute",
:uri "jar:file:file:/Users/borkdude/.m2/repository/org/clojure/clojure/1.11.0/clojure-1.11.0-sources.jar!/clojure/asm/Attribute.java",
:filename "/Users/borkdude/.m2/repository/org/clojure/clojure/1.11.0/clojure-1.11.0-sources.jar:clojure/asm/Attribute.java"}
{:class "clojure.asm.TypePath",
...
Am I imagining it or is flattenv
no longer a function in Clojure? I can’t seem to find anything on Google, but I could swear that I’ve used it before.
According to git
, it has never been a part of Clojure itself. Maybe you've seen it in some library.
There’s mapv and filterv. Maybe you've conflated the two?
What's the best way to read an untrusted edn string with line and column numbers attached as metadata? It appears that both clojure.edn
and clojure.tools.reader.edn
will track line numbers when given the right kind of input stream, and will use those line numbers in exceptions, but neither attaches them as metadata like clojure.core/read
does.
Perhaps https://github.com/borkdude/edamame will help you here, it's quite configurable so it's likely that you can tweak it to your likings
Looks perfect, @U04V15CAJ. Thanks!!
Good to hear! Let me know if you have any questions. This library is used as the parsing library in SCI (babashka, nbb, etc), clerk, etc. and has seen quite a lot of exposure, so it should be fairly battle tested.
Is this possible with case
:
(case [:a :b]
[:a :b] "a b combo"
[_ :b] "at least b"
)
Or does it not work like that?user=> (let [[x y] [:a :b]] (if (= [x y] [:a :b]) "a b combo" (if (= y :b) "at least b"))) "a b combo" user=> (let [[x y] [:c :b]] (if (= [x y] [:a :b]) "a b combo" (if (= y :b) "at least b"))) "at least b"
@U8WFYMFRU - without using core.match, you could probably get something similar, but a little more verbose, with cond
. BUT, you may be interested why exactly this isn't possible with case
: the clauses are compiled into a tableswitch on the JVM that provides constant lookup (instead of linear, like cond
). That's why they must be literals (need to be known at compile time) and they can't be ambiguous like in your example (because they are not compared at in order - they either exist in the lookup table, or not).
Right, compile time literals. That's how I understood it but wanted to ask to see other options. For practical purposes, I just went with cond
as I don't want to add core.match just for one function
OK :) I was surprised the first time I learned how case
actually works, so I thought I'd point it out. e.g. prep-hashes
does a lot of work to convert Clojure structures into integers that avoid hash-collisions and are densely packed: https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L6719-L6745
Ah cool, thanks for breaking down the implementation, that part I definitely did not know
https://github.com/clojure/core.match is what you’re looking for, I think
(clojure.core.match/match [:a :b]
[:a :b] "a b combo"
[_ :b] "at least b")
Good to know, thanks