This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-04-21
Channels
- # babashka (16)
- # beginners (182)
- # calva (13)
- # chlorine-clover (43)
- # clj-kondo (17)
- # cljs-dev (14)
- # cljsrn (19)
- # clojure (97)
- # clojure-argentina (7)
- # clojure-dev (45)
- # clojure-europe (7)
- # clojure-germany (5)
- # clojure-nl (4)
- # clojure-portugal (4)
- # clojure-romania (5)
- # clojure-spec (46)
- # clojure-uk (21)
- # clojuredesign-podcast (2)
- # clojurescript (159)
- # conjure (28)
- # core-async (7)
- # cursive (13)
- # datomic (17)
- # defnpodcast (9)
- # duct (1)
- # fulcro (45)
- # graphql (6)
- # jobs (7)
- # jobs-discuss (1)
- # juxt (3)
- # kaocha (4)
- # leiningen (12)
- # malli (5)
- # observability (1)
- # off-topic (50)
- # pathom (15)
- # re-frame (16)
- # reitit (5)
- # remote-jobs (21)
- # ring (7)
- # shadow-cljs (166)
- # test-check (6)
- # tools-deps (27)
- # xtdb (2)
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
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...?
Ah, so this is libraries?
That would not include applications, just open source libraries.
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
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
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.
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 🙂
Yes, the file I tried was the core.cljs from the ClojureScript source 🙂.
With Edamame, it parsed in 504ms
. With rewrite-cljs, 610ms
@U04V15CAJ 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}})
@U3Y18N0UC 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
Great, it works, thanks! 😄
Yes, I'm running both from ClojureScript, parsing the cljs.core
namespace source file
Which explains why certain things don't work if the cursor is above the ns
form (at the start of the file, for example).