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 PAA30825; Mon, 27 Sep 2004 15:32:03 +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 PAA31865 for ; Mon, 27 Sep 2004 15:32:01 +0200 (MET DST) Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.196]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id i8RDW1b0010484 for ; Mon, 27 Sep 2004 15:32:01 +0200 Received: by mproxy.gmail.com with SMTP id 79so3178499rnk for ; Mon, 27 Sep 2004 06:32:00 -0700 (PDT) Received: by 10.38.171.24 with SMTP id t24mr48941rne; Mon, 27 Sep 2004 06:32:00 -0700 (PDT) Received: by 10.38.75.19 with HTTP; Mon, 27 Sep 2004 06:31:00 -0700 (PDT) Message-ID: <7f8e92aa04092706317dae6556@mail.gmail.com> Date: Mon, 27 Sep 2004 16:31:00 +0300 From: Radu Grigore Reply-To: Radu Grigore To: Jon Harrop Subject: Re: [Caml-list] C++ STL and template features compared with OCaml parametric polymorphism and OO features Cc: caml-list In-Reply-To: <200409271411.30384.jon@jdh30.plus.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <20040925225246.48566.qmail@web53010.mail.yahoo.com> <200409270259.43863.jon@jdh30.plus.com> <7f8e92aa0409270350ce0eed2@mail.gmail.com> <200409271411.30384.jon@jdh30.plus.com> X-Miltered: at nez-perce with ID 41581651.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 2004:99 iterator:01 iterator:01 abstraction:01 generic:01 ocaml:01 irrelevant:01 sep:01 iterators:02 iterators:02 wrote:03 stl:03 data:03 functions:05 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Mon, 27 Sep 2004 14:11:30 +0100, Jon Harrop wrote: > > For the writter of the function there is a big difference, especially > > if it has to write the specialized versions. > > The equivalent to the writer of fold is the writer of an iterator. You have to > write specialized versions for each type of iterator just as you would have > to write your own fold. That's why I said iterators are another level of abstraction. The difference is that after you write the iterators code for a new sequence-like data structure all the "generic" functions, not only fold but also map and others, will automagically work on them. The simplest form of an "iterator" is implementing a "next" function for all sequences (although in this situation it is more of an "enumeration"). You should really check out the article cited by Vasili. It seems that we understend different things by "functional equivalent of an iterator", since you talk about the advantage of being able of going backwards a.s.o. which really is an irrelevant advantage. regards, radu ------------------- 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