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

> On Tue, 2004-09-28 at 00:04, Brian Hurt wrote:
> > On Mon, 27 Sep 2004, Jon Harrop wrote:
> 
> > 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. 
> 
> For templates all you need is a class with an operator()() method.
> 
> Dynamic dispatch is only needed if you need
> run time function variables (first class functions).

All this means is that the calling code, instead of calling foo->doit(), 
now instead calls (*foo)().  Not that big of a difference in coding 
volume.

And you still need dynamic dispatch because you're passing the superclass
type in.  Unless you're talking about templating the map/fold functions so
that you get a different instantiation for each call?

> 
> Heh .. it isn't a pain doing this in C++, its
> quite easy -- just use Felix. 
> 

:-)  I rest my case.

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