Fwd: Re: Dependency Injection

Oops, forgot reply-all. Again.
2011/9/16 Tony Morris <tonymorris [at] gmail [dot] com>
On 16/09/11 20:08, √iktor Ҡlang wrote:
>> Have you tried something like that:
>>
>> import java.lang.ThreadLocal
>>
>> class Parameter[A](initial:  A) {
>>     val tl = new ThreadLocal[A] {
>>         override def initialValue() : A = {
>>             initial
>>         }
>>       }
>>     def apply() = tl.get()
>>     def withValue[B](a : A, p : => B){
>>        val old = tl.get()
>>        tl.set(a)
>>        try{
>>            p
>>          }
>>        finally{tl.set(old)}
>>     }
>> }
>>
>>
:(
> Not that I don't like inventing wheels, but what's wrong with:
> http://www.scala-lang.org/api/current/scala/util/DynamicVariable.html
:(

Was I really that unclear?

--
Tony Morris
http://tmorris.net/


Hi, Tony,
Unfortunately, I think some of us *really really* need to see an example of the approach you're suggesting. I've seen you talk about it at least half a dozen times in various threads, and have never been able to figure out how to apply the solution you're suggesting. So please, please give an example like Russ requested!
From my perspective, the future of configuration lies in FRP. A reactive model is the only one that will allow you to safely make changes not merely at compile or load time, but at runtime where whole pieces of your system may need to be reloaded based upon a change to configuration. 
Kris 

Copyright © 2013 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland