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 UAA05616; Tue, 1 Apr 2003 20:44:39 +0200 (MET DST) 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 UAA06843 for ; Tue, 1 Apr 2003 20:44:38 +0200 (MET DST) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from opus.davidb.org (66-75-152-1.san.rr.com [66.75.152.1]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h31Iib528736 for ; Tue, 1 Apr 2003 20:44:37 +0200 (MET DST) Received: from davidb by opus.davidb.org with local (Exim 3.31 #1 (Debian)) id 190QkG-0000FN-00; Tue, 01 Apr 2003 10:44:28 -0800 Date: Tue, 1 Apr 2003 10:44:28 -0800 From: David Brown To: Alessandro Baretta Cc: Ocaml Subject: Re: [Caml-list] Typing problem with polymorphic variants Message-ID: <20030401184428.GA895@opus.davidb.org> References: <3E89CDA0.7090200@baretta.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3E89CDA0.7090200@baretta.com> User-Agent: Mutt/1.4i X-Spam: no; 0.00; caml-list:01 alessandro:01 baretta:01 foo:01 incompatible:01 val:01 checker:01 baz:01 variants:01 int:01 0200,:01 underlying:01 polymorphic:01 signatures:02 string:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Tue, Apr 01, 2003 at 07:34:24PM +0200, Alessandro Baretta wrote: > Why are "match-anything" functions of the kind of > > let f = function > | `Foo -> "foo" > | `Bar -> "bar" > | _ -> "?" > > incompatible with signatures like > > val f : [> `Foo ] -> string > ? > > There clearly is no case when a value of type [> `Foo] will > not be acceptable for f. So why does the type checker reject > this? I would apply the same question to the object system: why can a signature not hide methods of a class. Does making the signature more restrictive somehow hurt the type system? e.g.: class foo : object method baz : int end = object method baz = 5 method bar = 2 end gives: The class type object method bar : int method baz : int end is not matched by the class type object method baz : int end The public method bar cannot be hidden It seems to me this is the same kind of thing where struct's can contain definitions that are not in the signature, and that can be used to hide them. Is there some underlying reason that I'm missing? Perhaps assumptions the type system makes about the signature being complete? Dave Brown ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners