Hi!
I don't think I've seen the keyword virtual in Felix before.
Is it used in other places besides type classes?
\Klas
> From: skaller <[EMAIL PROTECTED]>
>
> The first case of typeclasses now works:
>
> //------------------------
> #import <flx.flxh>
> proc pr[t]:t="std::cout<<$1<<std::endl;" requires iostream;
>
> typeclass Eq[t,u] {
> virtual fun eq: t * u -> 2;
> virtual proc ppp: t;
> }
>
> instance Eq[int,int] {
> fun eq: int * int -> 2 = "$1==$2";
> proc ppp (x:int) { pr x; }
> fun fred: int -> int = "";
> }
>
>
> instance Eq[long,int] {
> fun eq: long * int -> 2 = "$1==$2";
> proc ppp (x:long) { pr x; }
> }
>
> fun jeq[r,s with Eq[r,s]] (x:r,y:s)=> x == y;
> fun keq[t with Eq[t,t]] (x:t,y:t)=> jeq(x,y);
> fun peq[t with Eq[t,t]] (x:t,y:t)=> keq(x,y);
> proc zzz[t with Eq[t,t]] (x:t) { ppp x; }
>
> pr$ peq$ 1,2;
> pr$ peq$ 1,1;
>
> zzz 1;
> //----------------------------
>
> There are some constraints, and some stuff which isn't
> finished and heaps which isn't tested.
>
> Typeclasses and instances have to be toplevel: that is,
> they can be nested in modules but NOT in functions.
>
> Instances must ground typeclass type variables: they
> cannot be polymorphic (the methods can be .. they
> can have extra type variables .. though this is not tested
> yet and probably won't work)
>
> You may not provide more than one instance for the
> same grounding of type variables.
>
> Typeclasses may only contain virtual functions and
> virtual procedures.
>
> Instances must instantiate these virtuals. They can
> also contain extra functions, which can be helper
> functions -- such functions are NOT available to
> the typeclass client, they're private implementation
> details of the instance.
>
> At the moment, overloading doesn't work and the
> instance checker only checks some virtual 'eq'
> has an instance .. it doesn't check the type
> of the instance is correct yet :)
>
>
> --
> John Skaller
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language