Public Vars

Back

pop-thread-bindings (clj)

(source)

function

(pop-thread-bindings)
Pop one set of bindings pushed with push-binding before. It is an error to pop bindings without pushing before.

Examples

hoplon/hoplon
(ns hoplon.binding
  (:refer-clojure :exclude [binding bound-fn])
  (:require [clojure.core  :as clj]
            [cljs.analyzer :as a]))

(defmacro binding
  "See clojure.core/binding."
  [bindings & body]
  (let [env           (assoc &env :ns (a/get-namespace a/*cljs-ns*))
        value-exprs   (take-nth 2 (rest bindings))
        bind-syms     (map #(:name (a/resolve-existing-var env %)) (take-nth 2 bindings))
        bind-syms'    (map (partial list 'quote) bind-syms)
        set-syms      (repeatedly (count bind-syms) gensym)
        setfn         (fn [x y]
                        {:push! `(fn []
                                   (let [z# ~x]
                                     (set! ~x ~y)
                                     (fn [] (set! ~x z#))))})
        thunkmaps     (map setfn bind-syms set-syms)]
    (a/confirm-bindings env bind-syms)
    `(let [~@(interleave set-syms value-exprs)]
       (hoplon.binding/push-thread-bindings ~(zipmap bind-syms' thunkmaps))
       (try ~@body (finally (hoplon.binding/pop-thread-bindings))))))
typedclojure/typedclojure
(ns ^:no-doc typed.ann.clojure
  "Type annotations for the base Clojure distribution."
  #?(:cljs (:require-macros [typed.ann-macros.clojure :as macros]))
  (:require [clojure.core :as cc]
            [typed.clojure :as t]
            #?(:clj [typed.ann-macros.clojure :as macros])
            #?(:clj typed.ann.clojure.jvm) ;; jvm annotations
            #?(:clj clojure.core.typed))
  #?(:clj
     (:import (clojure.lang PersistentHashSet PersistentList
                            APersistentMap #_IPersistentCollection
                            #_ITransientSet
                            IRef)
              (java.util Comparator Collection))))

#?@(:cljs [] :default [
cc/pop-thread-bindings [:-> t/Any]
cc/load [t/Str :* :-> t/Any]
cc/read-string [t/Str :-> t/Any]
cc/read [(t/alt (t/cat (t/? java.io.Reader))
                (t/cat java.io.Reader t/Bool)
                (t/cat java.io.Reader t/Bool t/Any (t/? t/Bool)))
         :-> t/Any]
cc/read+string [(t/alt (t/cat (t/? java.io.Reader))
                       (t/cat java.io.Reader t/Bool)
                       (t/cat java.io.Reader t/Bool t/Any (t/? t/Bool)))
                :-> '[t/Any t/Str]]
cc/read-line [:-> (t/U nil t/Str)]
cc/add-classpath [(t/U t/Str java.net.URL) :-> nil]
])