Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: 2004-09-26 (20:43)
From: skaller <skaller@u...>
Subject: Re: [Caml-list] C++ STL and template features compared with OCaml parametric polymorphism and OO features
On Mon, 2004-09-27 at 04:51, Jon Harrop wrote:

> I think you're thinking of a function to convert between 'a and 'b container 
> types. 

The requirement is for a polyadic map. 
Here is the type signature:

map: ('a -> 'b) -> 'a 'F -> 'b 'F

Here, 'F is a variable for 'list' or 'array'.
You cannot do that in Ocaml. 

Of course for given 'F, made of sums, products
and induction, you can write the
code for map_F, eg map_list, map_array, map_tree,
and you can do it 'mechanically'. But Ocaml can't.

Note: the output must have exactly the same shape
as the input: map preserves shape, it only changes
the values stored in the 'slots' of the data structure.
So a weird tree or graph has to come out isomorphic
to its input.

> You mean there is a trade-off of functionality between more- and less-capable 
> type systems?

No, I mean that trivial but useful cases of Object Orientation
exist but in general it doesn't work.

Similarly, trivial cases of polyadic programming
can be done with the trick of using iterators
or some other sequential representation such as Enums,
but it isn't a general solution -- it only 
works for sequences.

> > Accumulate can accept a function object argument.
> > C++ DOES have higher order functions.
> That statement is so HOF-definition dependent that it boils down to "C++ is 
> Turing complete".

I agree :)

> > [Did I miss something .. ? :]
> Good looking programmers.


John Skaller,
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: