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 PAA00654; Mon, 27 Sep 2004 15:54:14 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA31828 for ; Mon, 27 Sep 2004 15:54:13 +0200 (MET DST) Received: from herd.plethora.net (herd.plethora.net [205.166.146.1]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id i8RDsA2w013849 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Mon, 27 Sep 2004 15:54:13 +0200 Received: from bhurt.plethora.net (bhurt.plethora.net [205.166.146.49]) by herd.plethora.net (8.13.1/8.12.11) with ESMTP id i8RDs11T029767 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 27 Sep 2004 08:54:04 -0500 (CDT) Date: Mon, 27 Sep 2004 09:04:39 -0500 (CDT) From: Brian Hurt X-X-Sender: bhurt@localhost.localdomain To: Jon Harrop cc: caml-list Subject: Re: [Caml-list] C++ STL and template features compared with OCaml parametric polymorphism and OO features In-Reply-To: <200409271411.30384.jon@jdh30.plus.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Miltered: at nez-perce with ID 41581B82.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 extensively:01 stepanov:01 reinvented:01 generic:01 iterator:01 iterator:01 hofs:01 ocaml:01 ocaml:01 feasible:01 sep:01 lazy:02 iterators:02 iterators:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Mon, 27 Sep 2004, Jon Harrop wrote: > I think we are, because I think iterators are only really useful in an > imperative setting. Hence C++ programmers use them extensively but OCaml > programmers do not. Folds are simply not feasible in C++. I'm sure Stepanov > would have reinvented them if they had been... ;-) Two comments: First, iterators are usefull in a functional setting, for two reasons. The first is they allow lazy application of transformations. It's easy to define a map on an interator to do the transforms as the values get pulled out. And second, they provide a generic way to plug data structures together. All you need to write is a to_iterator and from_iterator for each data structure, and then all data structures can talk to each other. Second, you can do fold, map, iter, etc. in C++- it's just a pain. To emulate HOFs you define a new class with single virtual member function. The virtual member function then becomes your HOF. Of course, 1 line of Ocaml code has just become a dozen lines of C++, but that doesn't mean it can't be done... -- "Usenet is like a herd of performing elephants with diarrhea -- massive, difficult to redirect, awe-inspiring, entertaining, and a source of mind-boggling amounts of excrement when you least expect it." - Gene Spafford Brian ------------------- 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