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?
thanks!
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...
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
lol
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
Yes, you can pass exactly this option to edamame, itβs in the README
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 π
sql-korma
uses multiple namespaces per file, that's why I implemented support for multiple ns
forms per file π
Is that from JS?
Yes, I'm running both from ClojureScript, parsing the cljs.core
namespace source file
@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 :
auto-resolve is for resolving namespaced keywords: https://github.com/borkdude/edamame/blob/3fa04b714f55a4f1435ad045fb618b959d5a55bb/test/edamame/core_test.cljc#L192
you can pass that a map of aliases to namespaces
or :current
for the current namespace
Great, it works, thanks! π
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.