[bitc-dev] Extent of type class instances (MPJ look)
Jonathan S. Shapiro
shap at eros-os.org
Fri May 19 12:09:04 EDT 2006
Mark: this one is the note I promised for your reaction.
We have reached the point where we need to make a decision about the
extent of type class instances. There appear to be three possible
choices:
1. Instances are purely lexically scoped. The set of available instances
is determined by the set of instances that are lexically visible at the
point of instantiation (where "visible" means "you imported the
interface that defined it" -- instance declarations escape their
exporting interfaces as soon as the interface is imported)
2. Instances are scoped according to the outermost current unit of
compilation. An instance can appear later than its use, and this will be
resolved successfully.
3. Instances have universal scope. Only one instance for a particular
class over a particular set of types may exist in an entire program.
The problem I see with (2) is that the visibility for non-polymorphic
procedures is confusingly different (in the eyes of the programmer) from
the visibility of instances in polymorphic procedures.
The problem I see with (3) is that the programmer can now create
inadvertent impediments to scalability.
So what should we do here?
Mark: experience and advice on this would be particularly welcome.
shap
More information about the bitc-dev
mailing list