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: Zheng Li <li@p...>
Subject: Re: Why can't I call a function over a subclass?
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>

-- 
Zheng Li
http://www.pps.jussieu.fr/~li