Looking at class TryExpr in the compiler, we find
public Class getJavaClass() {
return tryExpr.getJavaClass();
}
Why are the types returned by each catch clause not involved in this calculation?
One could consider TryExpr to be rather similar to a CaseExpr : The various catch clauses are the explicit cases and the tryExpr is the "default" when no exception occurs. CaseExpr requires agreement of type across all explicit cases and the default.
In a more "type-ful" language, one cannot get away with:
int Foo(string x)
{
try
{
return int.Parse(x);
}
catch (FormatException)
{
return "What a dope!"; // Compiler error
}
}With a try, the body is the βnormalβ (non-exceptional) path
One could argue that the values of exceptional paths are still part of the contract of the expression. We have a try in order to provide regularity of output. We catch exceptions that we have a reasonable expectation might occur and that we know how to deal with in a reasonable manner.
(try
(Int32/Parse x)
(catch FormatException e "Doofus!"))
might not be good coding. It would be better either to return a default value, or, if we were being really type-ful, to return a option type. (Sorry.) Otherwise, we seem to be just pushing our FormatException to a type error somewhere else, as we are baking in an int return type for this expression but a string might result.
Then again, if no one is looking, no one will notice.
Credit this to my own type-perversion from spending too much time in C#/F#-land.
Thanks.
Over and out.getJavaClass() is not a type but a type hint, and seems like the hint should be the expected type of the body
That's a useful take for me to keep in mind. In the notes I'm making on type inference in the compiler, I had already made reference to the fact that user-supplied type tags are just hints. I think I'll strengthen that sentiment a bit.
Here's a small thing I noticed (happy to post to ask.clojure if that is helpful). Clojure Maven artifacts sometimes don't include a in their poms. But the Clojure parent pom does, and it is inherited. So you'll see "Parent POM for projects contributed to Clojure" as the description for Clojure artifacts that don't have a description. From a search on https://central.sonatype.com:
I created an internal support ticket for this. Thanks!
(looks like that's a private jira project, just in case you were hoping to share the work publicly)
Ah yes, I had forgotten about that.
I'm not sure that an ask topic would be useful, but it would be nice to have those filled in without also having to create and manage 50 tickets π
Yeah! An alternative idea would be to delete the description from the parent pom. I'll summarize the current state of artifact descriptions here in a bit.
Ok, whipped up a little babashka script:
clojure_artifacts_descs.clj
(ns clojure-artifacts-descs
(:require [babashka.http-client :as http]
[cheshire.core :as json]
[clojure.string :as str])
(:import (org.jsoup Jsoup)))
(defn- json-parse [s]
(json/decode s true))
(defn- text [doc sel]
(when-let [t (some-> (.select doc sel) (first) (.ownText))]
(when-not (str/blank? t) t)))
(let [summary (->> (http/get "")
:body
json-parse
:response
:docs
(mapv (fn [{:keys [a latestVersion]}]
(let [description (-> (http/get (format ""
a latestVersion a latestVersion))
:body
Jsoup/parse
(text "project > description"))]
{:artifact-id a :version latestVersion :description description})))
(sort-by :artifact-id))
with-desc (filterv :description summary)
without-desc (filterv #(nil? (:description %)) summary)]
(println "=== Artifacts With Descriptions: " (count with-desc))
(doseq [{:keys [artifact-id version description]} with-desc]
(println (format "%-35s %-25s %s" artifact-id version description)))
(println "\n=== Artifacts Without Descriptions: " (count without-desc))
(doseq [{:keys [artifact-id version]} without-desc]
(println (format "%-35s %-25s" artifact-id version))))
Which, as of today:
$ bb clojure_artifacts_descs.clj
=== Artifacts With Descriptions: 48
buildtest 0.2.6 Dummy project for build and deployment testing
clojure 1.12.3 Clojure core environment and runtime library.
clojure-contrib 1.1.0 Clojure user contributions library.
clojure-install 0.1.21 Clojure dependency installer
clojurescript 1.12.42 ClojureScript compiler and core runtime library.
core.async 1.9.829-alpha2 Facilities for async programming and communication in Clojure
core.cache 1.1.234 Cache library for Clojure.
core.contracts 0.0.6 A contracts programming library for Clojure
core.logic 1.1.0 A logic/relational programming library for Clojure
core.match 1.1.0 Optimized pattern matching and predicate dispatch for Clojure
core.memoize 1.1.266 A memoization library for Clojure
core.rrb-vector 0.2.0 RRB-Trees for Clojure(Script) -- see Bagwell & Rompf
core.specs.alpha 0.4.74 Specs for clojure.core
core.typed 0.6.0 An optional type system for Clojure β full system for annotating and type-checking.
core.typed-pom 0.8.0-alpha2 An optional type system for Clojure
core.typed.analyzer.common 0.8.0-alpha2 A variant of tools.analyzer.
core.typed.analyzer.js 0.8.0-alpha2 A variant of tools.analyzer.js.
core.typed.analyzer.jvm 0.8.0-alpha2 A variant of tools.analyzer.jvm.
core.typed.annotator.jvm 0.8.0-alpha2 Runtime type inference algorithm for core.typed and clojure.spec.
core.typed.checker.js 0.8.0-alpha2 An optional type system for ClojureScript β full system for annotating and type-checking.
core.typed.checker.jvm 0.8.0-alpha2 An optional type system for Clojure β full system for annotating and type-checking.
core.typed.infer 0.6.0 Runtime type inference algorithm for core.typed and clojure.spec.
core.typed.lang.jvm 0.8.0-alpha2 Extensible languages in Clojure, a la Racket's #lang.
core.typed.lib.clojure 0.8.0-alpha2 Type annotations and macros for the base Clojure distribution.
core.typed.lib.core.async 0.8.0-alpha2 Type annotations and macros for core.async.
core.typed.rt 0.6.0 An optional type system for Clojure β zero-dependency artifact for annotations only.
core.typed.runtime.jvm 0.8.0-alpha2 An optional type system for Clojure β zero-dependency artifact for annotations only.
core.unify 0.7.0 A unification library for Clojure
data.avl 0.2.0 Persistent sorted maps and sets with log-time rank queries
data.csv 1.1.0 A Clojure library for reading and writing comma separated value (csv) files
data.finger-tree 0.1.0 Persistent collections based on 2-3 finger trees.
data.fressian 1.1.0 Read/write Fressian from Clojure
data.int-map 1.3.0 A map optimized for integer keys
data.json 2.5.1 Generating/parsing JSON from/to Clojure data structures
data.xml 0.2.0-alpha9 Functions to parse XML into lazy sequences and lazy trees and emit these as text
google-closure-library 0.0-20250515-87401eb8 The Google Closure Library is a collection of JavaScript code designed for use with the Google Closure JavaScript Compiler. This non-official distribution was prepared by the ClojureScript team at
google-closure-library-third-party 0.0-20250515-87401eb8 The Google Closure Library is a collection of JavaScript code designed for use with the Google Closure JavaScript Compiler. This non-official distribution was prepared by the ClojureScript team at This package contains extensions to the Google Closure Library using third-party components, which may be distributed under licenses other than the Apache license. Licenses for individual library components may be found in source-code comments.
java.data 1.3.113 Utilities for working with Java beans from Clojure
jvm.tools.analyzer 0.6.2 An interface to Clojure's analyzer
pom.contrib 1.3.0 Parent POM for projects contributed to Clojure
pom.oss-deploy 0.0.19 Top-level parent POM enabling Sonatype OSS / central deployment for org.clojure artifacts from .
spec.alpha 0.5.238 Specification of data and functions
test.check 1.1.1 A QuickCheck inspired property-based testing library
tools.analyzer 1.2.0 An analyzer for Clojure code, written in Clojure and producing AST in EDN
tools.analyzer.js 0.1.0-beta5 Provides js-specific passes for tools.analyzer
tools.analyzer.jvm 1.3.2 Additional jvm-specific passes for tools.analyzer
tools.emitter.jvm 0.1.0-beta5 A JVM bytecode generator for ASTs compatible with tools.analyzer(.jvm).
tools.reader 1.5.2 A Clojure reader in Clojure
=== Artifacts Without Descriptions: 26
algo.generic 1.0.1
algo.monads 0.2.0
core.incubator 0.1.4
data.codec 0.2.0
data.generators 1.1.0
data.priority-map 1.2.0
data.zip 1.1.0
java.classpath 1.1.0
java.jdbc 0.7.12
java.jmx 1.1.0
math.combinatorics 0.3.0
math.numeric-tower 0.1.0
pom.baseline 0.0.19
test.generative 1.1.0
tools.build 0.9.2
tools.cli 1.2.245
tools.deps 0.26.1553
tools.deps.alpha 0.15.1254
tools.deps.cli 0.13.115
tools.deps.graph 1.1.90
tools.gitlibs 2.6.206
tools.logging 1.3.0
tools.macro 0.2.1
tools.namespace 1.5.0
tools.nrepl 0.2.13
tools.trace 0.8.0 This is great, thanks!