From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 7157DBC48 for ; Wed, 13 Apr 2005 16:11:22 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j3DEBLhc003695 for ; Wed, 13 Apr 2005 16:11:22 +0200 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id QAA15752 for ; Wed, 13 Apr 2005 16:11:21 +0200 (MET DST) Received: from shiva.jussieu.fr (shiva.jussieu.fr [134.157.0.129]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j3DEBLEx003692 for ; Wed, 13 Apr 2005 16:11:21 +0200 Received: from localhost (akasha.ijm.jussieu.fr [134.157.173.57]) by shiva.jussieu.fr (8.12.11/jtpda-5.4) with ESMTP id j3DEBLho003305 ; Wed, 13 Apr 2005 16:11:21 +0200 (CEST) X-Ids: 168 Date: Wed, 13 Apr 2005 16:11:19 +0200 (CEST) Message-Id: <20050413.161119.115918255.andrieu@ijm.jussieu.fr> To: matthieu.dubuget@laposte.net Cc: caml-list@inria.fr Subject: Re: [Caml-list] Coercion of arrays of objects (and some other containers) From: Olivier Andrieu In-Reply-To: <425CBE46.5000306@laposte.net> References: <20050413.095900.07644780.garrigue@math.nagoya-u.ac.jp> <425CBE46.5000306@laposte.net> X-Mailer: Mew version 4.1 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-1.7.2 (shiva.jussieu.fr [134.157.0.168]); Wed, 13 Apr 2005 16:11:21 +0200 (CEST) X-Antivirus: scanned by sophie at shiva.jussieu.fr X-Miltered: at nez-perce with ID 425D288A.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 425D2889.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at shiva.jussieu.fr with ID 425D2889.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 arrays:01 andrieu:01 andrieu:01 ijm:01 matthieu:01 dubuget:01 variance:01 covariance:01 subtyping:01 subtyping:01 subtype:01 subtype:01 supertype:01 supertype:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: Matthieu Dubuget [Wed, 13 Apr 2005]: > I'm sorry, but I feel stupid. > > The variance and covariance terms/notions appear often in this > list, and seems to be very basic notions. > > I tried to find explanation on internet but did not succeed. > > Could somebody point me some links to understand, please? I do not have a link but the idea (as I understand it) is simple : This concerns parameterized types ('a t) and how a subtyping relation on the parameter can yield a subtyping relation on the type. When the parameter is covariant : if a is a subtype of b then a t is a subtype of b t When the parameter is contravariant : if a is a subtype of b then b t is a subtype of a t For instance lists are covariant. [`A|`B|`C] is a supertype of [`A|`B] so a [`A|`B|`C] list is a supertype of [`A|`B] list. Function arguments are contravariant : ([`A|`B] -> unit) is a supertype of ([`A|`B|`C] -> unit). When you have a function that accepts A B or C, you can also view it as a function that accepts just A or B (qui peut le plus peut le moins). Records with mutable fields (or arrays) are neither covariant nor contravariant. Well maybe my terminology isn't quite correct but I hope you get the idea. -- Olivier