
On Fri, 25 Sep 2009 23:25:21 +0200, you wrote:
On Fri, Sep 25, 2009 at 8:14 PM, Job Vranish
wrote: Supposedly OCaml has an OO feature that does this but I haven't tried it out.
Indeed, OCaml has stuctural polymorphism, it's a wonderful feature.
*# let f myobj = myobj#foo "Hi !";; val f : < foo : string -> 'a; .. > -> 'a = <fun>*
IIRC, there has been work on Template Haskell for structural polymorphism.
Structural subtyping/polymorphism: Pros: - an object can be coerced to any compatible type, the types do not have to be specified ahead of time, that is at compile time. Cons: - may be overly permissive; some coercions might not make sense semantically. I wonder how Haskell will minimize the cons, since it is strongly typed. I forgot to add: that even if strong typing could be measured on "sum" numerical scale, I don't know whether Haskell has a higher "measure/metric" than OCaml, in the strong typing area. -- Regards, Casey