Creating a dynamic var

2013-01-03 Thread Brian Marick
Why does this: (def ^{:dynamic true} bar 33) … work to create a dynamic var, but this: (intern *ns* (with-meta 'foo {:dynamic true}) 33) … doesn't? (Looking more for the justification than mechanics.) Occasional consulting on programming technique Contract programming

Re: Creating a dynamic var

2013-01-03 Thread Timothy Baldridge
There's about 3-4 CLJ tickets related to this. The issue is that :dynamic is only read once: when the var is created. If you need to change a var to be dynamic, you can set it manually with .setDynamic. Personally I think it's simply an artifact of how defs are created, and it's never been

Re: Creating a dynamic var

2013-01-03 Thread Aaron Cohen
The issue here is that the documentation for intern says that it: Finds or creates a var named by the symbol name in the namespace ns (which can be a symbol or a namespace), setting its root binding to val if supplied. The namespace must exist. The var will adopt any metadata from the name

Re: Creating a dynamic var

2013-01-03 Thread Brian Marick
On Jan 3, 2013, at 12:12 PM, Timothy Baldridge tbaldri...@gmail.com wrote: If you need to change a var to be dynamic, you can set it manually with .setDynamic. Perhaps `.setDynamic` should be promoted to be a clojure function? I kind of wish I didn't have subject-to-change method calls

Re: Creating a dynamic var

2013-01-03 Thread Timothy Baldridge
Perhaps the doc needs to be updated then. The var does indeed adopt all metadata from the symbol, it just doesn't execute any code based on that metadata. Timothy On Thu, Jan 3, 2013 at 11:17 AM, Aaron Cohen aa...@assonance.org wrote: The issue here is that the documentation for intern says