From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id MAA01321; Mon, 19 Nov 2001 12:17:52 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id MAA01862 for ; Mon, 19 Nov 2001 12:17:51 +0100 (MET) Received: from leia.mandrakesoft.com (office.mandrakesoft.com [195.68.114.34]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id fAJBHpb15942 for ; Mon, 19 Nov 2001 12:17:51 +0100 (MET) Received: by leia.mandrakesoft.com (Postfix, from userid 505) id 77EA6578F; Mon, 19 Nov 2001 12:14:57 +0100 (CET) To: Jacques Garrigue Cc: caml-list@inria.fr Subject: Re: [Caml-list] [Q]: Co(ntra)variance and subtyping? References: <20011116203745.A59514@qiao.in-berlin.de> <002001c17035$c722aa80$3363e195@pazo> <20011119093329G.garrigue@kurims.kyoto-u.ac.jp> From: Pixel Date: 19 Nov 2001 12:14:56 +0100 In-Reply-To: <20011119093329G.garrigue@kurims.kyoto-u.ac.jp> Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Jacques Garrigue writes: [...] > > well, you forgot polymorphic variants, which do use subsumption: > > > > # let switch = function `On -> `Off | x -> x;; > > val switch : ([> `Off | `On] as 'a) -> 'a = > > # (switch `On, switch `Whatever);; > > - : _[> `Off | `On] * _[> `Off | `On | `Whatever] = `Off, `Whatever > > This, again, is row polymorphism, not subsumption. > The difference between (row/parametric) polymorphism and subsumption > is that for the former you must explicitely leave some free variable > in the type (the presence of which is proved by the "as 'a" or "_"), > while the latter also works on ground types (without variables). # let switch = function `On -> `Off | `Off -> `On;; val switch : [< `On | `Off] -> [> `Off | `On] = # `On;; - : [> `On] = `On # switch `On;; - : _[> `Off | `On] = `Off I still call this subsumption. > Both polymorphic variants and objects uss both polymorphism and > subtyping, but without implicit subsumption. The subsumption is not implicit is the type of "switch", but it is implicit in the use of the function. It is also implicit in the definition of "switch". That's why for the programmer, it is subsumption. ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr