On Tue, 2006-11-14 at 09:36 +0000, Rhythmic Fistman wrote:
> I don't really understand typeclasses so of course I suspect
> that they could be a solution.
Lol. Well, a typeclass is just a set of functions that
characterise a type (or types).
So you can write an algorithm which works for all
types of a particular kind, i.e. a generic algorithm.
typeclass Pix[image, pixel] {
virtual fun get: image * int * int -> pixel;
virtual proc blit: image * (image * int * int);
..
}
proc Zdraw[with Pix[Image,pixel]
(base: image, sprites: array[image * int * int])
{
blit ....
}
It's kind of like virtual dispatch in C++, except your
instances can be optimised.
instance Pix[rgb_image, rgb] ....
It's much like an unimplemented C++ template,
with implemented specialisations, except that the
typing is sound.
--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language