From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.0 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 0FA52BC69 for ; Thu, 18 Oct 2007 18:49:24 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAFQrF0dA6ba5kGdsb2JhbACOTQIBAQcCBhMRB4En X-IronPort-AV: E=Sophos;i="4.21,296,1188770400"; d="scan'208";a="18234707" Received: from nf-out-0910.google.com ([64.233.182.185]) by mail4-smtp-sop.national.inria.fr with ESMTP; 18 Oct 2007 18:49:23 +0200 Received: by nf-out-0910.google.com with SMTP id e27so186972nfd for ; Thu, 18 Oct 2007 09:49:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; bh=CJftNRa1RGw2VK6tUVwYQUK7MtmXp1gPPFrfkhxk4Qc=; b=VClVRoJQUInInDQkBm5pSyPnm1xPNJ4OhSpLTyk43TsujmYm4AOS3uWE835WxDunpqvXSVQLSyiEbpS5P+mwwlEAMS4qC0q8dg8cp0aaqt4hHWQCA5EqnDm6MfUhDArjNxcuyV74TBWGbB2UgbmuLDHbm+B9Q4kQPNBDWEk2PqU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; b=roevX4t8oJw4pMbDvNGmcbcH0+U8JkNKadAbTeXyQz2KsUueZL5uK81vqU4G8kfIlLSWIA8ZkIg/+wwfZH5zGapU63uSvtyQ7W4nnAN6JeP/N1FbbjCjPZWn3kkm7QkmkVlhVRWCCdUWxOnG8RsGVVP3ETxk+Z3iNlA9Wl7ScL0= Received: by 10.86.54.3 with SMTP id c3mr580567fga.1192726161112; Thu, 18 Oct 2007 09:49:21 -0700 (PDT) Received: from ?192.168.0.5? ( [87.88.165.197]) by mx.google.com with ESMTPS id y2sm2440545mug.2007.10.18.09.49.18 (version=SSLv3 cipher=RC4-MD5); Thu, 18 Oct 2007 09:49:19 -0700 (PDT) Message-ID: <47178E8C.6020304@lix.polytechnique.fr> Date: Thu, 18 Oct 2007 18:49:16 +0200 From: Arnaud Spiwack User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) MIME-Version: 1.0 To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Smells like duck-typing References: <377673.31302.qm@web54602.mail.re2.yahoo.com> <47176B4A.5000807@janestcapital.com> <47176DB6.7090700@lix.polytechnique.fr> <471771A7.3010402@janestcapital.com> <47177585.6030208@lix.polytechnique.fr> <1192725564.5999.51.camel@rosella.wigram> In-Reply-To: <1192725564.5999.51.camel@rosella.wigram> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: Arnaud Spiwack X-Spam: no; 0.00; lix:01 subtypes:01 subtypes:01 subtyping:01 wrote:01 arnaud:01 arnaud:01 caml-list:01 overridden:02 covariant:02 inheritance:03 inheritance:03 inherited:04 inherited:04 generally:04 skaller wrote : > The soundness theory is simple: methods have to be covariant, > but mutators have to be contravariant, and since mutators > are also method they have to be *invariant*, and invariance > effectively means an OO class cannot have subtypes. > You got that part wrong. I means that subtypes have the same types for the same methods (not subtypes, exactly the same types), but it can be extended with extra methods (you can be slighlty looser using specialisation of the self-type). That's how things work. And inheritance usually needs to enforce the same invariant condition, for the same reasons (since other method inside the inherited class could make black-box uses of the overridden method... its type cannot change in general). Thus that goes to "generally, all inherited values are subtypes" (rational is : if you need to enforce a certain subtyping property, it needs to be enforced internally during inheritance as well). Arnaud Spiwack