Fork me on GitHub
#sci
<
2022-12-02
>
borkdude16:12:42

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 :))

borkdude16:12:01

$ ./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