Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: David Teller <David.Teller@e...>
Subject: Re: [Caml-list] Re: Why can't I call a function over a subclass?
Sure. I'm just saying that this default behaviour is disconcerting.

In addition to which, while it does appear in the documentation, it's
rather well hidden inside section 3.11 "Polymorphic methods" -- even
though this is not a method.

Cheers,
 David

On Fri, 2007-10-05 at 12:53 +0200, Zheng Li wrote:
> David Teller <David.Teller@ens-lyon.org> writes:
> > I agree with Luca that it's disconcerting. 
> > When r is a class, I would expect 
> 
> >  let f (x:r) (y:r) =...
> This expression says f accept arguments of type [r], what you mean to say is: f
> accept any arguments belong to [r]'s subtypes family. Then say it with
> 
> # let f (x:#r) (y:#r) = x#get_x = y#get_x
> val f : #r -> #r -> bool = <fun>
>