On Fri, Jul 4, 2014 at 4:30 PM, Rob Earhart <[email protected]> wrote:
> On struct/union declarations with "implements" clauses: are you thinking
> these would just be asserting that the struct/union implements an
> interface, or would you also require that the "implements" clause be there
> in order to implement the interface?
>
Neither.
If present, the implements clause causes the compiler to auto-generate a
method that constructs the interface from the object, and the object is
required to provide the needed methods (provisionally - we can complicate
this later).
If a struct/union declaration does not specify an implements clause, then
the "X:'a as Y:SomeInterface" works exactly if there is an instance
definition for Castable 'a 'SomeInterface. The intended use would be for
the instance method to invoke the SomeInterface constructor and return an
interface object. What actually happens depends on how the programmer
implements the typeclass instance.
It's intentional here that a third party can specify an interface
acquisition mechanism. And given that typeclass instances will be named, we
aren't bound to a single solution at a given ('a, 'Someinterface).
It's *really* a wrapper notion.
Also: are you thinking that only structs & unions would support interfaces?
>
Not necessarily. I think the better question is: what types can you get
interface X from. The answer is: any type for which Castable 'a X has a
typeclass instance.
We're going to need sugar around this, but I want to gain experience with
it before I decide what sugar I think we want.
This idea that there may exist typeclasses that have an intimate
relationship with the language semantics is a very seductive idea. The
Castable type class, here, is known to the compiler in the same sense that
int32 and string are known to the compiler. Castable is part of the
compiler runtime. But the beauty of it is that it's a user-extensible part
of the compiler runtime...
shap
_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev