clojure

jf 2026-01-26T04:09:43.696879Z

I just discovered something interesting from following my curiosity, but it appears that clojure.string/lower-case works on chars too. I see that (at least in my version) the function basically does a toString, before a toLowerCase:

user> (r/source str/lower-case)
(defn ^String lower-case
  "Converts string to all lower-case."
  {:added "1.2"}
  [^CharSequence s]
  (.. s toString toLowerCase))
nil
user> 
This isn't exactly documented officially; so my question is, can I count on this internal toString to skip doing an str if I am expecting chars as inputs?

Alex Miller (Clojure team) 2026-01-26T04:16:07.082869Z

No, you should expect the clojure.string functions to take instances of CharSequence, which I think is doc’ed in the namespace docstring

Alex Miller (Clojure team) 2026-01-26T04:17:12.959379Z

That it works with chars is an accident of implementation

jf 2026-01-26T04:35:37.846649Z

ok so to clarify, do not count on that internal toString to always be there? Got it, thanks!

Yevgeni Tsodikov 2026-01-26T20:35:53.976049Z

If you know the input is a char, you can just use Character/toLowerCase ^char c and skip clojure.string entirely. > can I count on this internal toString to skip doing an str if I am expecting chars as inputs? Would it be possible to validate the input at some boundary? Otherwise, you can have some very odd, but technically working, edge cases:

(clojure.string/lower-case {:NAME "JF"})
=> "{:name \"jf\"}"

Alex Miller (Clojure team) 2026-01-26T21:04:06.677339Z

the API expectations for clojure.string are documented in the namespace docstring, other inputs are undefined. adding validation checks here would make this slower for all current users of these functions.

Yevgeni Tsodikov 2026-01-26T21:07:22.510099Z

Oh sorry, I meant my reply for @jf.slack-clojurians. I didn't imply any code changes for clojure.string are needed.

jf 2026-01-27T00:44:30.173879Z

@evg.tso thank you for the note on Character/toLowerCase! I didnt know that existed! definitely makes my code simpler 🙂 In my case, the input is guaranteed to be a character because of where it's coming from, so I dont have to worry about edge cases. @alexmiller definitely understandable, and glad to have the team take this stand!

Samuel Ludwig 2026-01-26T16:04:41.874719Z

Any prior art in parsing MBOX files (via clojure)? trying to do some misc analysis on a google-takeout dump- currently trying to roll my own

2026-01-30T09:05:16.207739Z

I attempted that in the past and mbox had enough edge cases that Javamail didn't work well enough for me.

2026-01-26T16:24:10.799159Z

Javamail has some mbox stuff

❤️ 1
Samuel Ludwig 2026-01-26T17:30:09.144369Z

thanks! taking a look now, looks like the current iteration is under org.eclipse.angus/angus-mail+`jakarta.mail/jakarta.mail-api` if I'm following these ownership-changes correctly

phronmophobic 2026-01-26T17:33:00.210569Z

Looks like someone was recently trying something similar, https://baecher.dev/stdout/incremental-backups-of-gmail-takeouts/

2026-01-26T17:37:38.482279Z

will need to update my priors, been along time since I've actually touched javamail, and the world keeps turning

leonoel 2026-01-26T17:25:37.654699Z

Is there a way to define a class or interface with a static final field from clojure, without writing java or generating bytecode ? Context - I want to use VarHandle on a clojure deftype field, but performance overhead is prohibitive unless the VarHandle is declared static final.

ghadi 2026-01-26T17:31:42.349579Z

none that will satisfy your use-case

😞 2
ghadi 2026-01-26T17:32:31.929869Z

assuming you want to CAS on a field or use one of the relaxed atomics? do you mind filing an https://ask.clojure.org/?

Alex Miller (Clojure team) 2026-01-26T17:34:13.480389Z

The only thing that comes to mind is gen-class creates a static public final for its :state

2026-01-26T17:40:53.990129Z

here is the ask I wrote for it https://ask.clojure.org/index.php/10369/add-atomic-field-updaters-to-deftype

2026-01-26T17:41:38.252059Z

here is some discussion in #clojure-dev https://clojurians.slack.com/archives/C06E3HYPR/p1616525665013300

leonoel 2026-01-26T17:45:28.241789Z

@alexmiller the doc for gen-class :state mentions final but not static, is there a way to force static ?

2026-01-26T17:49:24.384629Z

another thing you could do with static fields (not final) is using them as inline caches https://clojurians.slack.com/archives/C03S1KBA2/p1761340327219339?thread_ts=1761326860.782729&cid=C03S1KBA2

exitsandman 2026-01-26T17:49:25.941499Z

IMHO your best bet at that stage is to just write the minimal Java shim, unless you want to dive into the bytecode compilation rabbit hole. virgil makes it a very tolerable experience in dev, arguably more so than gen-class

➕ 2
leonoel 2026-01-26T17:55:46.519269Z

@hiredman thanks, I have the exact same problem indeed

exitsandman 2026-01-26T17:59:57.055339Z

Note that as far as I can see in that case the class is emitted with a static, but non-final field. You'd need to compile a to achieve what you need. E: to that end, I wonder if eval ing a (fn ) and calling it in clinit could work