This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-09-18
Channels
- # announcements (1)
- # babashka (15)
- # beginners (152)
- # calva (28)
- # circleci (1)
- # clj-kondo (24)
- # cljsrn (8)
- # clojure (137)
- # clojure-berlin (3)
- # clojure-czech (2)
- # clojure-dev (20)
- # clojure-europe (69)
- # clojure-finland (5)
- # clojure-france (3)
- # clojure-italy (11)
- # clojure-my (1)
- # clojure-nl (4)
- # clojure-uk (15)
- # clojuredesign-podcast (1)
- # clojurescript (13)
- # conjure (15)
- # cursive (13)
- # datomic (41)
- # deps-new (50)
- # events (1)
- # fulcro (9)
- # graalvm (27)
- # joker (2)
- # kaocha (11)
- # off-topic (22)
- # pathom (48)
- # rdf (6)
- # reagent (25)
- # reitit (47)
- # reveal (10)
- # ring-swagger (1)
- # rum (4)
- # sci (27)
- # shadow-cljs (73)
- # tools-deps (49)
- # vrac (2)
- # xtdb (4)
clj-kondo has a linter which checks for a try
without a catch
or finally
. This made me curious and led me to this commit
https://github.com/clojure/clojure/commit/6c0c37e048f49ee5cd3afa79ce461abbc6a0c367
Anyone know the history/rationale behind this?
There is one try without catch/finally in the locking macro. Not sure why it's there, but it has a subtle implication for the bytecode, if I remember correctly
@slipset (try x (catch Exception _))
has slightly different semantics than (do x)
even if no exception is thrown
user=> (clj-java-decompiler.core/decompile (try :dummy))
// Decompiling class: user$fn__198
import clojure.lang.*;
public final class user$fn__198 extends AFunction
{
public static final Keyword const__0;
public static Object invokeStatic() {
return user$fn__198.const__0;
}
@Override
public Object invoke() {
return invokeStatic();
}
static {
const__0 = RT.keyword(null, "dummy");
}
}
I don’t have the details on hand, but I recall that Clojure seemed to emit more bytecode ops than java in to do a try-catch and I was confused why
There’s more local clearing probably
I think that is nice to clojure have (try ... #_(catch ...))
for REPL proposes (just comment the catch
part for dev)
And also nice kondo
warns you about that
that may be it @alexmiller maybe I’ll redo my example again to remember - wish I would have noted it