chlorine-clover 2020-04-21

I also tested edamame, parsing core.cljs to benchmark comparing with the current implementation. It's almost the same speed, so I think I'll keep the current approach

out of curiosity, did you happen to try on clojure.core or clojurescript.core?

Yes, the file I tried was the core.cljs from the ClojureScript source šŸ™‚. With Edamame, it parsed in 504ms. With rewrite-cljs, 610ms

i recently looked at file sizes of real-world clojure code and found something like the following:

1k:  73042
  2k:  22604
  4k:  16474
  8k:   7887
 16k:   3027
 32k:   1014
 64k:    331
128k:    108
256k:     21
512k:      6
  1M:      2
  4M:      3
for the left column, 16k means roughly, not larger than 16k, but greater than 8k. for the right column, that's the total number of files that were in a range.

@sogaiu What are those stats from? I'm curious what "real-world clojure code" is public...?

yes, i fetched releases from clojars

Ah, so this is libraries?

whatever is on clojars

That would not include applications, just open source libraries.

i think there are some apps there too, but i didn't try to count

i suspect they are mostly libraries though

Just curious, since "most" real world Clojure is proprietary / behind closed doors, as far as I know...

āž• 1

i do have a collection of things fetched from github as well loosely based on andy.fingerhut's haironfire work, but i haven't tried to count against those

so libraries don't count as real world?

just playing with you šŸ™‚

poor phrasing on my part

i should have said clojars to begin with

NP. I was just wondering where the stats came from and what you were implying by that...

If it's "can we parse all this public code with tools.reader", yeah, that's a very real concern.

i collected the code for testing of a tree-sitter grammar for clojure -- there is some weird stuff out there

šŸ‘šŸ» 1

Apropos namespaces, I have been wondering for awhile how when I execute something via Chlorine it knows the correct namespace.

Also curious if you can have multiple namespace declarations in a file, and how that works out (I’m assuming the Java rules of files/packages prevent that...).

@mattias504 It uses the current cursor position, and searches backwards. The first ns form it finds, is the one it uses šŸ™‚

Which explains why certain things don't work if the cursor is above the ns form (at the start of the file, for example).

Yes, probably... to be honest I never tested too much evaluating code before a ns form šŸ™‚

I mostly notice it when trying to run tests or my inspect namespace command.

Interesting, thanks!

Well, running tests on current namespace can be something I should look at... it's not rare to Clojure sources to have comments before the namespace.

Yeah, I'd say that if you hit the start of the file with only comments/whitespace without finding a ns then you could look forward for one.

sql-korma uses multiple namespaces per file, that's why I implemented support for multiple ns forms per file šŸ™‚

Is that from JS?

@borkdude by the way... I wasn't able to use a default tag reader. The code below doesn't work:

(eda/parse-string "#some [:name]" {:reader {:default tagged-literal}})

@mauricio.szabo try:

user=> (eda/parse-string "#some [:name]" {:tools.reader/opts {:default tagged-literal}})
#some [:name]

:readers (plural) is recognized as a convenience, but other options for tools reader you can pass like this

Yes, that solved it šŸ™‚ Also, how do I use :auto-resolve?

When I tried to parse clojurescript core, I ended up replacing all :: to a single :

you can pass that a map of aliases to namespaces

or :current for the current namespace

Great, it works, thanks! šŸ˜„

Yes, I'm running both from ClojureScript, parsing the cljs.core namespace source file

šŸ‘ 1