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 LAA15651; Sun, 26 Sep 2004 11:42:47 +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 LAA14343 for ; Sun, 26 Sep 2004 11:42:46 +0200 (MET DST) Received: from smtp003.mail.ukl.yahoo.com (smtp003.mail.ukl.yahoo.com [217.12.11.34]) by concorde.inria.fr (8.13.0/8.13.0) with SMTP id i8Q9gjeC013875 for ; Sun, 26 Sep 2004 11:42:46 +0200 Received: from unknown (HELO yahoo.fr) (sejourne?kevin@83.114.104.177 with plain) by smtp003.mail.ukl.yahoo.com with SMTP; 26 Sep 2004 09:42:45 -0000 Message-ID: <41569027.7030508@yahoo.fr> Date: Sun, 26 Sep 2004 11:47:19 +0200 From: sejourne_kevin User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040528 Debian/1.6-7 X-Accept-Language: fr-fr MIME-Version: 1.0 To: Radu Grigore , caml-list Subject: Re: [Caml-list] C++ STL and template features compared with OCaml parametric polymorphism and OO features References: <20040925225246.48566.qmail@web53010.mail.yahoo.com> <200409260234.50929.jon@jdh30.plus.com> <7f8e92aa04092522313d47820d@mail.gmail.com> In-Reply-To: <7f8e92aa04092522313d47820d@mail.gmail.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 41568F15.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 2004:99 pervasives:01 printf:01 printf:01 ocamlc:01 -pp:01 ocaml:01 ocaml:01 lib:01 sep:01 preprocessor:02 namely:02 module:03 macros:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Radu Grigore wrote: > On Sun, 26 Sep 2004 02:34:50 +0100, Jon Harrop wrote: > >>For example, to sum the floating-point elements of a container in C++, one >>might write: > > > This example is slightly unfair to C++. In the OCaml code: > > >>let sum fold_left c = fold_left ( +. ) 0. c >>sum List.fold_left [0.; 1.; 2.; 3.; 4.] >>sum Array.fold_left [|0.; 1.; 2.; 3.; 4.|] > > > ...you use _two_ library functions (namely List.fold_left and > Array.fold_left). Surely you should at least use one for C++ :) not two library, but _three_ if you count module Pervasives :) > regards, > radu > PS: ok, maybe it's unfair to ocaml now that I used macros.. No it's totaly fair. There is a 'cpp' preprocessor for ocaml. #define P(x) (fst x) (snd x) (fst x) #define S(x) (snd x) let x = ("world","hello");; Printf.printf "%s %s %s %s\n" S(x) P(x);; ocamlc -pp /lib/cpp test.ml ------------------- 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