Skip to end of metadata
Go to start of metadata

Motivation

Clojure (1.3.0/2.0) has included new features around marking vars dynamic. This is done via metadata on the var. If a dynamic var is detected and no metadata is provided on the var, it will print a warning message when the namespace is loaded that looks like the following:

While these warnings are trivial to fix when declaring a var with def it isn't currently possible to mark a var dynamic if it is declared via declare.

Obstacles

  • Simply adding metadata on declare would introduce a situation where at the time of defniniton the re-def would overwrite the metadata. Currently there is no way to examine the metadata that exists when re-deffing a var brought in via declare

Use Cases

  • declare
  • functions that take primitives
Labels:
  1. Mar 19, 2011

    This works already:

    (declare ^:dynamic fred)

    user=> (meta #'fred)
    {:ns #<Namespace user>, :name fred, :dynamic true, :declared true, :line 27, :file "NO_SOURCE_PATH"}