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: brogoff <brogoff@s...>
Subject: Re: [Caml-list] C++ STL and template features compared with OCaml parametric polymorphism and OO features
On Mon, 27 Sep 2004, Brian Hurt wrote:
> 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...

I've thought for a while that a hybrid of C++, Ada, and Pascal, with the awful
C++ syntax fixed, pointers restricted, and especially downward funargs, would
be an amusing imperative language, and it would address tha second problem you
mention, without requiring GC. But functional languages are more amusing :-).

I don't think that iterator based libraries is the right thing in an
OCaml (or SML or Haskell) setting.

-- 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