On 26/06/2009, at 9:36 PM, john skaller wrote: > I don't like the STL iterator stuff much for Felix. So we have this > little > problem:
Just some notes: example: we can do this (which Haskell cannot): //// typeclass A[T] { virtual fun f: T -> T; } typeclass B[T] { inherit A[T]; } instance[T] A[T] { fun f: T -> T = "$1"; } instance A[int] { fun f: int -> int = "$1+1"; } open[T] B[T]; println$ f 1; println$ f 1.3; //// Note that instances (specialisations) can be fully polymorphic, and also that overlapping instances are allowed provided one is more specialised (fully contained in) the other. This this code prints 2 1.3 A polymorphic (non-)specialisation like the first instance given is similar to a virtual with a default body. But you cannot instantiate f in B, even though it is inherited. In particular, you can't do this: typeclass B[T] { fun g... fun f(x)=>g(x); } which is what we want: actually we want A to be Container and declare virtual iterate, then define fold_left using it. In B= Sequence we define iterate using STL begin/end functions. We see here that whilst a Sequence "is-a" Container, derivation (inheritance) isn't the same as specialisation. C++ (template) classes can solve this (for member functions). There's a difference between specialising a class (inheritance) and specialising its type variables (instantiation). -- john skaller skal...@users.sourceforge.net ------------------------------------------------------------------------------ _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language