Passing an environment around

Fergus Henderson
Thu, 9 Nov 2000 03:24:22 +1100

On 27-Oct-2000, Josť Romildo Malaquias <> 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


> 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

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 <>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <>  |     -- the last words of T. S. Garp.