Understood. I was using a configuration example as a kind of shorthand for 
a larger set of problems - most of which are multithreaded and will be 
dealing with occasionally changing results. As usual, its a tricky area, 
but not as difficult as achieving the same result in some other 
environments, fortunately.

On Wednesday, December 10, 2014 11:22:39 AM UTC, Gary Verhaegen wrote:
>
> Although if you do not expect the config to change, you do not need to 
> wrap the delay in an atom. The atom in Steven Yi's solution is only there 
> to allow the combination of (delay) executing the operation strictly once 
> but also (atom) allow for changing the underlying value (i.e. clear the 
> cache).
>
> On Wednesday, 10 December 2014, Andy Dwelly <andyd...@gmail.com 
> <javascript:>> wrote:
>
>> Thanks to everyone for the responses. I was completely unaware of 
>> core.memoize although I think there is a very convincing case for delay; I 
>> certainly accept the thread safety problem with the existing code. Action 
>> this day on that one!
>>
>> I'm inclined to go down the @@ syntactic route, simply in order to enjoy 
>> the look of horror on my co-worker's faces when I check it in.
>>
>> On Wednesday, December 10, 2014 4:45:16 AM UTC, Steven Yi wrote:
>>>
>>> No reason really, just ended up writing it that way for the example. 
>>> (Maybe subconsciously I didn't want to think about pointer pointers 
>>> and wanted to break up the notation. :P) 
>>>
>>> On Tue, Dec 9, 2014 at 11:18 PM, Fluid Dynamics <a209...@trbvm.com> 
>>> wrote: 
>>> > 
>>> > 
>>> > On Tuesday, December 9, 2014 7:19:27 PM UTC-5, Steven Yi wrote: 
>>> >> 
>>> >> Hi Andy, 
>>> >> 
>>> >> Just my two cents here, but I don't think memoize makes sense here 
>>> myself 
>>> >> due to this not being referentially transparent, and I think Andrey's 
>>> >> comment on delays makes more sense to me.  You could do something 
>>> like this: 
>>> >> 
>>> >> (def conf (atom (delay (read-and-expensively-parse "somefile.xml")))) 
>>> >> 
>>> >> (defn config [] 
>>> >>   @(deref conf)) 
>>> > 
>>> > 
>>> > Why not just @@conf? It seems to work at my REPL, at least, to unpeel 
>>> two 
>>> > onion layers of indirection. 
>>> > 
>>> > -- 
>>> > You received this message because you are subscribed to the Google 
>>> > Groups "Clojure" group. 
>>> > To post to this group, send email to clo...@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+u...@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 a topic in the 
>>> > Google Groups "Clojure" group. 
>>> > To unsubscribe from this topic, visit 
>>> > https://groups.google.com/d/topic/clojure/FaPliPRgJBI/unsubscribe. 
>>> > To unsubscribe from this group and all its topics, send an email to 
>>> > clojure+u...@googlegroups.com. 
>>> > For more options, visit https://groups.google.com/d/optout. 
>>>
>>  -- 
>> 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 unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to