This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-12-02
Channels
- # adventofcode (63)
- # announcements (21)
- # babashka-sci-dev (1)
- # beginners (24)
- # biff (2)
- # calva (78)
- # cherry (6)
- # clj-commons (3)
- # clj-kondo (7)
- # clojure (91)
- # clojure-austin (2)
- # clojure-bay-area (6)
- # clojure-denmark (1)
- # clojure-europe (45)
- # clojure-nl (1)
- # clojure-norway (16)
- # clojure-portugal (3)
- # clojure-uk (1)
- # clojurescript (20)
- # conjure (11)
- # datalevin (13)
- # datomic (5)
- # emacs (14)
- # etaoin (15)
- # events (7)
- # fulcro (9)
- # funcool (1)
- # honeysql (26)
- # joyride (4)
- # kaocha (3)
- # lambdaisland (2)
- # malli (7)
- # off-topic (22)
- # pathom (29)
- # portal (58)
- # practicalli (8)
- # rdf (25)
- # reagent (14)
- # sci (3)
- # scittle (37)
- # shadow-cljs (10)
- # slack-help (2)
- # spacemacs (7)
- # sql (7)
- # tools-deps (1)
- # xtdb (2)
In SCI, until today defn
and defmacro
were "special forms", as in, there was built-in support for it, unlike it being macros like in Clojure.
I now changed this in a branch, to be normal macros, so the only special form is fn*
and def
.
When analyzing a large amount of defn
-s, this takes about 5% more time.
E.g loading spec 100 times costs:
$ ./bb "(time (dotimes [i 100] (require '[clojure.spec.alpha] :reload)))"
"Elapsed time: 2306.254417 msecs"
whereas before it took:
$ /opt/homebrew/bin/bb "(time (dotimes [i 100] (require '[clojure.spec.alpha] :reload)))"
"Elapsed time: 2248.706792 msecs"
Maybe the difference is small enough to have more compatibility with Clojure here. Some tools expect fn
, defn
and defmacro
to be macros (and to have docstrings :))$ ./bb "(doc defn)"
-------------------------
clojure.core/defn
([name doc-string? attr-map? [params*] prepost-map? body] [name doc-string? attr-map? ([params*] prepost-map? body) + attr-map?])
Macro
Same as (def name (fn [params* ] exprs*)) or (def
name (fn ([params* ] exprs*)+)) with any doc-string or attrs added
to the var metadata. prepost-map defines a map with optional keys
:pre and :post that contain collections of pre or post conditions.
$ /opt/homebrew/bin/bb "(doc defn)"
$
1
👍 4
For who is interested looking at the PR: https://github.com/babashka/sci/pull/847/files