The defonce macro (like many others) allows you to specify some metadata as the first argument. This metadata is often used to give the compiler hints about how the symbol will be used.
In this case, the keyword ^:dynamic metadata is provided, allowing the compiler to know that this character must be optimized for dynamic bounce at runtime using binding .
Asterisks are simply an agreement to let other developers know that the symbol is not connected regularly. They should pay attention to the fact that it may not work as you expect.
For example, the binding form is a local thread, and the symbol is returned only to the region of the form.
(defonce ^:dynamic *my-var* false) (binding [*my-var* true] *my-var*) ;; true *my-var* ;; false
Trying to access the *my-var* value from outside the binding may not return the expected value.
Since this form was designated using the *special-var* convention, we do not expect normal behavior and can read the documentation or examine the code before referencing the symbol elsewhere.
source share