Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Why can't I call a function over a subclass?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-10-05 (08:08)
From: Luca de Alfaro <luca@d...>
Subject: Fwd: [Caml-list] Why can't I call a function over a subclass?
I meant to say: it seems to be that Ocaml breaks the principles of oo
programming for no good reason, in this case.


---------- Forwarded message ----------
From: Luca de Alfaro <>
Date: Oct 5, 2007 1:08 AM
Subject: Re: [Caml-list] Why can't I call a function over a subclass?
To: Inria Ocaml Mailing List <>

I don't understand this.  I thought the whole idea of oo programming was
that you could use a subclass in place of a superclass...

I also thought that the strict typing of Ocaml was there to avoid runtime
errors, but if so, why does it complain in this situation, when no runtime
error can possibly happen?

It seems to me that the idea of oo programming is broken for no good


On 10/5/07, Florian Hars <> wrote:
> Luca de Alfaro schrieb:
> > The absurdity continues:
> This is not absurd, this is the documented correct behaviuor.
> If *you* decide that f must only accept arguments of *exactly*
> type r, the typechecker enforces your decision, as it does if
> you decide that f may also accept subtypes of r (as long as your
> decisions are consistent within he type system).
> Yours, Florian.