Public Vars

Back

with-meta (clj)

(source)

variable

(with-meta obj m)
Returns an object of the same type and value as obj, with map m as its metadata.

Examples

thheller/shadow-cljs
(ns shadow.remote.runtime.cljs.js-builtins
  (:require
    [goog.object :as gobj]
    [clojure.core.protocols :as p]))

(extend-protocol p/Datafiable
  ;; FIXME: this is kind of a bad idea
  ;; can't do this for all objects, since none of the CLJS types implement this
  ;; protocol either. the protocol dispatch will end up using object
  ;; FIXME: this could detect CLJS types to some extent
  ;; or should it just implement the protocols for the types?
  object
  (datafy [o]
    (if-not (identical? (.-__proto__ o) js/Object.prototype)
      o
      (with-meta
        (->> (gobj/getKeys o)
             (reduce
               (fn [m key]
                 (assoc! m key (gobj/get o key)))
               (transient {}))
             (persistent!))
clojure/core.typed
(ns ^:no-doc clojure.core.typed.import-macros
  (:require [clojure.core :as core]))

;copied from ClojureScript
(defmacro import-macros [ns [& vars]]
  (core/let [ns (find-ns ns)
             vars (map (core/fn [vsym]
                         {:pre [(symbol? vsym)]
                          :post [(instance? clojure.lang.Var %)]}
                         (let [v (ns-resolve ns vsym)]
                           (assert v (str "Internal error: " vsym " does not exist"))
                           v))
                       vars)
             syms (map (core/fn [^clojure.lang.Var v] 
                         {:pre [(instance? clojure.lang.Var v)]
                          :post [(symbol? %)]}
                         (core/-> v .sym (with-meta {:macro true})))
                       vars)
             defs (map (core/fn [sym var]
                         {:pre [(symbol? sym)
                                (instance? clojure.lang.Var var)]}
                         `(do (def ~sym (deref ~var))
                              ;for AOT compilation
                              (alter-meta! (var ~sym) 
                                           merge
                                           (dissoc (meta ~var) :ns :name)
                                           {:macro true})))
                       syms vars)]
    `(do ~@defs
         :imported)))
noprompt/meander
(ns multimethods
  (:refer-clojure :exclude [defmethod defmulti])
  (:require
   #?(:clj [clojure.core :as clj] :cljs [cljs.core :as cljs])
   [meander.epsilon :as m]))

(defmacro defmethod
  [mf [& lhr] & body]
  (swap! cache_ assoc-in [mf lhr] body)
  (let [ptrns (get @cache_ mf)]
    `(-set-fn ~(with-meta mf {:tag `MultiMeanderFn})
              (fn [& ~'argsv]
                (m/match ~'argsv
                  ~@(loop [[[l r] & more] ptrns xs []]
                      (if l
                        (recur more (conj xs l (cons `do r)))
                        xs)))))))
mhuebert/maria
(ns cells.cell
  (:refer-clojure :exclude [bound-fn get])
  (:require [clojure.core :as core]
            [cells.util :as util]
            [applied-science.js-interop :as j]))

(defmacro defcell
  "Defines a named cell."
  [the-name & body]
  (let [[docstring body] (if (string? (first body))
                           [(first body) (rest body)]
                           [nil body])
        [options body] (if (and (map? (first body)) (> (count body) 1))
                         [(first body) (rest body)]
                         [nil body])
        f `(fn [~'self] ~@body)]
    `(do
       ;; support re-evaluation without breaking links
       (declare ~the-name)
       (let [prev-cell# ~the-name]
         (def ~(with-meta the-name options)
           ~@(when docstring (list docstring))
           (if (some? prev-cell#)
             (~'cells.cell/update-cell* prev-cell# ~f)
             (~'cells.cell/cell* ~f)))))))
typedclojure/typedclojure
(ns ^:no-doc typed.cljc.checker.check-impl
  (:require [clojure.core.typed.current-impl :as impl]
            [typed.cljc.analyzer :as ana2]
            [typed.cljc.checker.check.binding :as binding]
            [typed.cljc.checker.check.catch :as catch]
            [typed.cljc.checker.check.const :as const]
            [typed.cljc.checker.check.do :as do]
            [typed.cljc.checker.check.fn :as fn]
            [typed.cljc.checker.check.if :as if]
            [typed.cljc.checker.check.invoke :as invoke]
            [typed.cljc.checker.check.let :as let]
            [typed.cljc.checker.check.letfn :as letfn]
            [typed.cljc.checker.check.local :as local]
            [typed.cljc.checker.check.loop :as loop]
            [typed.cljc.checker.check.map :as map]
            [typed.cljc.checker.check.quote :as quote]
            [typed.cljc.checker.check.recur :as recur]
            [typed.cljc.checker.check.set :as set]
            [typed.cljc.checker.check.set-bang :as set!]
            [typed.cljc.checker.check.throw :as throw]
            [typed.cljc.checker.check.try :as try]
            [typed.cljc.checker.check.vector :as vec]
            [typed.cljc.checker.check.with-meta :as with-meta]))

(defmethod -check ::ana2/binding   [expr expected] (binding/check-binding     expr expected))
(defmethod -check ::ana2/catch     [expr expected] (catch/check-catch         expr expected))
(defmethod -check ::ana2/const     [expr expected] (const/check-const         expr expected))
(defmethod -check ::ana2/do        [expr expected] (do/check-do               expr expected))
(defmethod -check ::ana2/fn        [expr expected] (fn/check-fn               expr expected))
(defmethod -check ::ana2/if        [expr expected] (if/check-if               expr expected))
(defmethod -check ::ana2/invoke    [expr expected] (invoke/check-invoke       expr expected))
(defmethod -check ::ana2/let       [expr expected] (let/check-let             expr expected))
(defmethod -check ::ana2/letfn     [expr expected] (letfn/check-letfn         expr expected))
(defmethod -check ::ana2/local     [expr expected] (local/check-local         expr expected))
(defmethod -check ::ana2/loop      [expr expected] (loop/check-loop           expr expected))
(defmethod -check ::ana2/map       [expr expected] (map/check-map             expr expected))
(defmethod -check ::ana2/quote     [expr expected] (quote/check-quote         expr expected))
(defmethod -check ::ana2/recur     [expr expected] (recur/check-recur         expr expected))
(defmethod -check ::ana2/set       [expr expected] (set/check-set             expr expected))
(defmethod -check ::ana2/set!      [expr expected] (set!/check-set!           expr expected))
(defmethod -check ::ana2/throw     [expr expected] (throw/check-throw         expr expected))
(defmethod -check ::ana2/try       [expr expected] (try/check-try             expr expected))
(defmethod -check ::ana2/vector    [expr expected] (vec/check-vector          expr expected))
(defmethod -check ::ana2/with-meta [expr expected] (with-meta/check-with-meta expr expected))