On Sun, 2007-10-28 at 00:34 -0700, Erick Tryzelaar wrote:
> A while ago, when we had a typeclass inheritance like this:

> instance FooBar[int] {}
> 
> in order to do:
> 
> open FooBar[int];
> 
> However, now it looks like you don't need the extra "instance FooBar[int] {}":

> 
> So, the question is, is this just a coincidence that it's working now,
> or is this really not needed any more?

First you could note that 'open FooBar[int]' will work even if
there are NO instances of anything!

Remember it is opening a specialisation of the typeclass,
instances are irrelevant during lookup.

During instantiation, any function actually used has to
have a corresponding instance.

But lo, there are no functions in FooBar, and even
if there were it wouldn't matter, because you're not
calling them.

Yes this did change somewhere, I think when I removed
some checks that got in the way, but it seems now you
only have to instantiate functions you use .. not sure,
but if you have

        typeclass X[t] = { virtual fun f .. virtual fun g .. }

and you call f for X[int], I think you can instantiate X[int]
with f and forget g .. not sure if an instance actually has
to match on all members.

It might even be interesting to allow multiple instances
of the same types for a typeclass, provided no duplicate
definitions, eg:

        instance X[int] { fun f ..  .. }
        instance X[int] { fun g ..  }

i.e like namespace, instances might be extensible even though
typeclasses aren't.


The only problem here (in both cases) would be if we had
dictionary passing like Haskell, in that case all the
instance functions would be required and all the typeclasses
including FooBar above would have to be instantiated
(since this would determine the 'dictionary' layout).

BTW: such a dictionary would appear to be just a C++ class,
and the typeclass just an abstract class, and the dispatch
would be ordinary virtual function dispatch.



-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to