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  wrote:

> 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 symbol.  Returns the var.
>
>
> It seems reasonable to me that intern should respect the metadata being 
> copied when it does the "create".
>
>
>
> On Thu, Jan 3, 2013 at 1:12 PM, Timothy Baldridge wrote:
>
>> 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 enough of a pain to anyone to suggest a better solution.
>>
>> What's being asked for is some sort of trigger. When :dynamic is set in
>> the metadata call setDynamic. This seems like a bad idea to me.
>>
>> Timothy Baldrige
>>
>>
>> On Thu, Jan 3, 2013 at 10:44 AM, Brian Marick wrote:
>>
>>> 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 in Ruby and Clojure
>>> Latest book: /Functional Programming for the Object-Oriented Programmer/
>>> https://leanpub.com/fp-oo
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clojure@googlegroups.com
>>> Note that posts from new members are moderated - please be patient with
>>> your first post.
>>> To unsubscribe from this group, send email to
>>> clojure+unsubscr...@googlegroups.com
>>> For more options, visit this group at
>>> http://groups.google.com/group/clojure?hl=en
>>>
>>
>>
>>
>> --
>> “One of the main causes of the fall of the Roman Empire was that–lacking
>> zero–they had no way to indicate successful termination of their C
>> programs.”
>> (Robert Firth)
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>>
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>



-- 
“One of the main causes of the fall of the Roman Empire was that–lacking
zero–they had no way to indicate successful termination of their C
programs.”
(Robert Firth)

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Creating a dynamic var

2013-01-03 Thread Brian Marick

On Jan 3, 2013, at 12:12 PM, Timothy Baldridge  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 like .setDynamic and 
.setRawRoot floating around in my code. 

Besides, it just seems... wrong... to make the dynamicity of a var be a static, 
read-time property. 


Occasional consulting on programming technique
Contract programming in Ruby and Clojure
Latest book: /Functional Programming for the Object-Oriented Programmer/
https://leanpub.com/fp-oo

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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 symbol.  Returns the var.


It seems reasonable to me that intern should respect the metadata
being copied when it does the "create".



On Thu, Jan 3, 2013 at 1:12 PM, Timothy Baldridge wrote:

> 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 enough of a pain to anyone to suggest a better solution.
>
> What's being asked for is some sort of trigger. When :dynamic is set in
> the metadata call setDynamic. This seems like a bad idea to me.
>
> Timothy Baldrige
>
>
> On Thu, Jan 3, 2013 at 10:44 AM, Brian Marick  wrote:
>
>> 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 in Ruby and Clojure
>> Latest book: /Functional Programming for the Object-Oriented Programmer/
>> https://leanpub.com/fp-oo
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>>
>
>
>
> --
> “One of the main causes of the fall of the Roman Empire was that–lacking
> zero–they had no way to indicate successful termination of their C
> programs.”
> (Robert Firth)
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

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 enough of a pain to anyone to suggest a better solution.

What's being asked for is some sort of trigger. When :dynamic is set in the
metadata call setDynamic. This seems like a bad idea to me.

Timothy Baldrige


On Thu, Jan 3, 2013 at 10:44 AM, Brian Marick  wrote:

> 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 in Ruby and Clojure
> Latest book: /Functional Programming for the Object-Oriented Programmer/
> https://leanpub.com/fp-oo
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>



-- 
“One of the main causes of the fall of the Roman Empire was that–lacking
zero–they had no way to indicate successful termination of their C
programs.”
(Robert Firth)

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

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 in Ruby and Clojure
Latest book: /Functional Programming for the Object-Oriented Programmer/
https://leanpub.com/fp-oo

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en