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 VAA10505; Thu, 21 Oct 2004 21:12:00 +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 VAA10752 for ; Thu, 21 Oct 2004 21:11:59 +0200 (MET DST) Received: from mail.davidb.org (adsl-64-172-240-129.dsl.sndg02.pacbell.net [64.172.240.129]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id i9LJBvpW006048 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 21 Oct 2004 21:11:58 +0200 Received: from davidb by mail.davidb.org with local (Exim 4.42 #1 (Debian)) id 1CKiLs-0004g0-MW; Thu, 21 Oct 2004 12:11:56 -0700 Date: Thu, 21 Oct 2004 12:11:56 -0700 From: David Brown To: Jon Harrop Cc: caml-list Subject: Re: [Caml-list] Polymorphism and the "for" loop Message-ID: <20041021191156.GA17933@old.davidb.org> References: <200410211950.43396.jon@jdh30.plus.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200410211950.43396.jon@jdh30.plus.com> User-Agent: Mutt/1.5.6i X-Miltered: at concorde with ID 417809FD.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 caml-list:01 2004:99 inferred:01 val:01 argued:01 inferred:01 inference:01 polymorphic:01 objects:02 unit:03 unit:03 dave:03 wrote:03 oct:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Thu, Oct 21, 2004 at 07:50:43PM +0100, Jon Harrop wrote: > > Considering the following code objects to the expression in the "for" loop not > having the type "unit": > > # for i=0 to 3 do 1 done;; > Warning: this expression should have type unit. > - : unit = () > > why is "g" in the following code inferred to have the polymorphic type (unit > -> 'a) rather than (unit -> unit)? > > # let f g = for i=0 to 3 do g () done;; > val f : (unit -> 'a) -> unit = Because its only a warning, not an error. g is allowed to return any type. It could be argued that the loop expression must be of type unit, then this could also be inferred by type inference. Dave ------------------- 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