Public Vars

Back

with-local-vars (clj)

(source)

macro

(with-local-vars name-vals-vec & body)
varbinding=> symbol init-expr Executes the exprs in a context in which the symbols are bound to vars with per-thread bindings to the init-exprs. The symbols refer to the var objects themselves, and must be accessed with var-get and var-set

Examples

frenchy64/fully-satisfies
(ns io.github.frenchy64.fully-satisfies.non-leaky-macros.clojure.core
  "Implementations of clojure.core macros that don't leak implementation details."
  (:refer-clojure :exclude [locking binding with-bindings sync with-local-vars
                            with-in-str dosync with-precision with-loading-context
                            with-redefs delay vswap! lazy-seq lazy-cat future
                            pvalues])
  (:require [clojure.core :as cc]))

(defmacro non-leaky-with-local-vars
  "Like clojure.core/with-local-vars, except body cannot leak try/catch syntax."
  [name-vals-vec & body]
  `(cc/with-local-vars ~name-vals-vec
     (do ~@body)))

(defmacro with-local-vars
  [& args]
  `(non-leaky-with-local-vars ~@args))