clojure-dev

dmiller 2023-01-04T20:11:57.384879Z

I've been trying to figure out why ClojureCLR has a failing test, coming from clojure.test-clojure.compilation. The test is the equivalent of

(list? (:arglists (meta #'when)))
[premature posting -- continuing] This is a test coming from ClojureJVM, so not my problem (re list? vs some other test). this returns true, and indeed the value is a PersistentList . However,
user=> (defn f [x] x)
#'user/f
user=> (class (:arglists (meta #'f)))
clojure.lang.PersistentVector$ChunkedSeq
and list? defintely fails on that. The :arglists value is computed by clojure.core/sigs and as I look at that, it is going to create PV$ChunkedSeq no matter what. So how does when and in fact everything I've tested in clojure.core have a PersistentList. Can it be that this is getting scrubbed by passing through AOT-compilation? In other words, the initialization code in the class file creates a PersistentList ? Because that's what I'm seeing in ClojureCLR on Framework 4.x, where we still have AOT-compilation. When I run on .Net Core and 6.0 and 7.0, there is no AOT, so when 's arglist is not a list. Help!

2023-01-04T20:33:22.200329Z

Almost certainly it is aot compilation, the chunked seq won't be special cased in the compiler, so it will be serialized using pr-str to embed in the generated class file, and then the static init of the generated class file will use read-string to deserialize where it will come out as a list

2023-01-04T20:34:30.855289Z

The reason it is only sot compilation and not the regular compilation is in regular compilation the var metadata doesn't need to get serialized into bytecode

dmiller 2023-01-04T20:36:23.561699Z

On ClojureCLR, it comes out in the init method in the assembly as a call to PersistentList.create.

2023-01-04T21:33:26.104389Z

yeah, I was incorrect, about the pr-str/read-string, the compiler does handle seqs specially, but the way it does, they all get turned into PersistentList

borkdude 2023-01-04T20:22:28.548779Z

@dmiller FWIW, I stopped using list? for this exact reason and use seq? pretty much everywhere instead of it

Alex Miller (Clojure team) 2023-01-04T20:24:51.304579Z

Without spending some time on it, can’t definitively answer why, but i do think seq? is a better test here

dmiller 2023-01-04T20:26:03.916789Z

Believe me, I spent way too much time on this. I don't wish that on anyone else. Shall I post an issue on it, or do you want to?

Alex Miller (Clojure team) 2023-01-04T20:29:13.076799Z

An issue to do what?

dmiller 2023-01-04T20:30:34.153879Z

The test is ClojureJVM code. I just inherited it. I'll change it on ClojureCLR, no problem. Never mind.

Alex Miller (Clojure team) 2023-01-04T20:31:03.798239Z

Yeah, I don’t think this is high priority to do anything about

dmiller 2023-01-04T20:32:21.729059Z

Understood. As I said, never mind. (I can't ignore it over here, so I'll make the change.)