Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] C++ STL and template features compared with OCaml parametric polymorphism and OO features
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
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 17:54:35 +0100, Jon Harrop <jon@jdh30.plus.com> wrote:
> On Monday 27 September 2004 14:31, Radu Grigore wrote:
> > 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.
> 
> I think this is the core of what we disagree on. 

Indeed. I think this is the problem.
Efficiency is indeed a constraint that limits the usefuleness of
iterators and the "find" function is a good example of this. When
using STL you have to remember that for certain data structures (e.g.
set) you have to use member functions if you want better performance
that is available only on that data structure.

But I do not think that it is such a severe limitation. For iter, map,
and fold efficiency is not a problem. At least no counter-example
comes to mind. Even more, the same implementation of fold can be O(n)
for a list and O(n log n) for a tree. This is because the fold itself
is O(n), while particular iterators are either O(1) or O(log n).

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