I'm sorry I've been away for awhile: leftover work and a very full
week-and-a-half helping out family.
skaller wrote:
> 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.
This looks clean, with decently understandable syntax. I can think
of a few untested cases already.
> Typeclasses and instances have to be toplevel: that is,
> they can be nested in modules but NOT in functions.
It wouldn't make sense if typeclasses were nested in functions.
-Pete
-------------------------------------------------------------------------
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