Browse thread
[Caml-list] C++ STL and template features compared with OCaml parametric polymorphism and OO features
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2004-09-27 (13:32) |
From: | Radu Grigore <radugrigore@g...> |
Subject: | Re: [Caml-list] C++ STL and template features compared with OCaml parametric polymorphism and OO features |
On Mon, 27 Sep 2004 14:11:30 +0100, Jon Harrop <jon@jdh30.plus.com> 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