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 RAA19799; Thu, 28 Jun 2001 17:45:26 +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 RAA19979 for ; Thu, 28 Jun 2001 17:45:25 +0200 (MET DST) Received: from smtprt16.wanadoo.fr (smtprt16.wanadoo.fr [193.252.19.183]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f5SFjO908651 for ; Thu, 28 Jun 2001 17:45:24 +0200 (MET DST) Received: from villosa.wanadoo.fr (193.252.19.122) by smtprt16.wanadoo.fr; 28 Jun 2001 17:45:24 +0200 Received: from debian (62.161.109.138) by villosa.wanadoo.fr; 28 Jun 2001 17:45:07 +0200 Received: from moi by debian with local (Exim 3.22 #1 (Debian)) id 15Fdu0-0000GY-00 for ; Thu, 28 Jun 2001 17:40:20 +0200 To: caml-list@inria.fr Subject: Re: [Caml-list] Type inference problem References: <20010628172348.A24964@boblycat.com> From: Remi VANICAT Date: 28 Jun 2001 17:40:20 +0200 In-Reply-To: <20010628172348.A24964@boblycat.com> Message-ID: <87ithg1ul7.dlv@wanadoo.fr> User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.0.103 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Vasilij Karpow writes: > Can anyone explain why O'Caml specializes the following: > > let simple ?fn list = > let fn = match fn with > | Some fn -> fn > | None -> fun t -> t in > let rec print = function > | [] -> () > | x :: xs -> print_endline (fn x); print xs > in > print list > > let _ = > simple ["1"]; > simple ~fn:(fun i -> string_of_int i) [1] > > > to: val simple : ?fn:(string -> string) -> string list -> unit it's easy. If the value was polymorphic, you would be authorized to write : simple [1; 2; 3; 4; 5] which is unsound. -- Rémi Vanicat vanicat@labri.u-bordeaux.fr http://dept-info.labri.u-bordeaux.fr/~vanicat ------------------- 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