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 RAA21511; Wed, 25 Jun 2003 17:05:40 +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 RAA20948 for ; Wed, 25 Jun 2003 17:05:36 +0200 (MET DST) Received: from aomori.annexia.org (annexia.force9.co.uk [212.56.101.183]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h5PF5aj10961 for ; Wed, 25 Jun 2003 17:05:36 +0200 (MET DST) Received: from rich by aomori.annexia.org with local (Exim 3.36 #1 (Debian)) id 19VBq3-00049o-00 for ; Wed, 25 Jun 2003 16:05:35 +0100 Date: Wed, 25 Jun 2003 16:05:35 +0100 To: caml-list@inria.fr Subject: [Caml-list] OCaml not automatically specialising a polymorphic function Message-ID: <20030625150535.GA15972@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.4i From: Richard Jones X-Spam: no; 0.00; freshmeat:01 ltd:98 inefficient:01 ocaml:01 surprising:01 assembler:01 int:01 polymorphic:01 business:96 module:03 data:03 let:04 functions:05 max:06 type:07 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk - max3.ml ------------------------------------------------------------ let max a b = if a > b then a else b in print_int (max 2 3);; ---------------------------------------------------------------------- Looking at the assembler, OCaml doesn't work out that "max" has type max : int -> int -> int, and so it generates very inefficient code. This is a bit surprising because (I think) max can't be called from outside the module, and the one place where it is called specifies the type. So I'm guessing here that OCaml doesn't really optimize across functions? Rich. -- Richard Jones. http://www.annexia.org/ http://freshmeat.net/users/rwmj Merjis Ltd. http://www.merjis.com/ - all your business data are belong to you. "I wish more software used text based configuration files!" -- A Windows NT user, quoted on Slashdot. ------------------- 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