Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support trailing metadata in defn #567

Closed
borkdude opened this issue May 31, 2021 · 1 comment
Closed

Support trailing metadata in defn #567

borkdude opened this issue May 31, 2021 · 1 comment

Comments

@borkdude
Copy link
Collaborator

(defn foo
  ([])
  ([_ _])
  {:x true})

Merely for compatibility

borkdude added a commit that referenced this issue Jun 1, 2021
borkdude added a commit to babashka/babashka that referenced this issue Jun 1, 2021
@borkdude
Copy link
Collaborator Author

For future reference, we started supporting this because the omniconf library used this. I found this back using grasp. It's actually the only library in my entire .m2 folder which uses the trailing metadata map.

(ns trailing-meta)

(require
 '[clojure.core.specs.alpha :as specs]
 '[clojure.spec.alpha :as s]
 '[grasp.api :as g])

(s/def ::defn (s/cat :defn #{'defn} :args ::specs/defn-args))
(s/def ::defn-trailing-attr-map (s/and ::defn (fn [conformed]
                                                (->> conformed
                                                     :args :fn-tail second :attr-map))))

(def matches (g/grasp "/Users/borkdude/.m2" ::defn-trailing-attr-map))

;; (prn (s/conform ::defn-trailing-attr-map (first matches)))
(run! (comp prn meta) matches)
{:line 272, :column 1, :url "jar:file:/Users/borkdude/.m2/repository/com/grammarly/omniconf/0.4.3/omniconf-0.4.3.jar!/omniconf/core.clj"}
{:line 312, :column 1, :url "jar:file:/Users/borkdude/.m2/repository/com/grammarly/omniconf/0.4.3/omniconf-0.4.3.jar!/omniconf/core.clj"}
{:line 372, :column 1, :url "jar:file:/Users/borkdude/.m2/repository/com/grammarly/omniconf/0.4.3/omniconf-0.4.3.jar!/omniconf/core.clj"}
{:line 390, :column 1, :url "jar:file:/Users/borkdude/.m2/repository/com/grammarly/omniconf/0.4.3/omniconf-0.4.3.jar!/omniconf/core.clj"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant