Fergus Henderson wrote:
On 27-Oct-2000, José Romildo Malaquias <romildo@urano.iceb.ufop.br> wrote:
On Fri, Oct 27, 2000 at 09:07:24AM -0700, Jeffrey R. Lewis wrote:
Yes, as implemented using the dictionary translation, implicit parameterization can lead to loss of sharing, exactly in the same way that overloading (and HOF in general) can lead to loss of sharing.
However, I can imagine that a compiler might chose to implement implicit parameters more like dynamic variables in lisp. Each implicit param essentially becomes a global variable, implemented as a stack of values - the top of the stack is the value currently in scope. This would avoid the sharing problem nicely.
I suppose your implementation of implicit parameterization in GHC and Hugs uses the dictionary translation, right?
I believe so.
Sorry - that wasn't clear from my reply - yes, implicit parameters in GHC are compiled using the dictionary translation.
Would an alternative implementation based on a stack of values be viable
Yes.
and even done?
Unlikely ;-)
That's a shame ;-)
An alternative is to store the values of the implicit parameters in thread-local storage rather than global storage. But this is more complicated. It may also be less efficient on some targets (depending on how efficiently thread-local storage is implemented).
I don't know the costs associated w/ thread local storage - how is it likely to compare w/ the dictionary passing implementation? --Jeff