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.
Would an alternative implementation based on a stack of values be viable
Yes.
and even done?
Unlikely ;-)
Does it have serious drawbacks when compared with the dictionary translation technique?
In the form described by Jeff Lewis above, yes, it does: it's not thread-safe. 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). -- Fergus Henderson <fjh@cs.mu.oz.au> | "I have always known that the pursuit | of excellence is a lethal habit" WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.