English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] [ANN] The Missing Library
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-04-28 (12:13)
From: skaller <skaller@u...>
Subject: Re: [Caml-list] [ANN] The Missing Library
On Wed, 2004-04-28 at 21:31, Yaron M. Minsky wrote:
> On Wed, 2004-04-28 at 04:24, skaller wrote:
> > On Wed, 2004-04-28 at 14:31, Brian Hurt wrote:
> > > On Mon, 26 Apr 2004, Martin Berger wrote:
> > 
> > > I'm wondering what concepts Ocaml can't express/enforce? 
> > 
> > Iterators. 
> Why can't you do this kind of in ocaml?  Returning something like a
> "next" function would seem to give you a very basic (but usable)
> iterator.  Which part of the iterator abstraction can't you do?

I suggest you try it. I don't know how to answer the question.
I think the answer is 'C++ templates provide functorial
polymorphism (polyadicity), Ocaml has no such expressive power.'

HOF's like 'map' and 'fold' make sense
for polynomial data structures -- lists and trees etc.
But you have to write 'List.map' or 'Array.map'. There
is no single 'map' which works for all data structures
in Ocaml.

There is in C++, and its a one line idiom:

// STL copy
for(; i!=e; ++i) *o++ = *i++;

Fold is as easy to define (called Accumulate in STL).

These definitions are polyadic. They work for ALL
data structures -- provided they have iterators
of course :D

A polyadic 'map' and 'fold' for ML can be defined
for polynomial data types (lists, trees etc).
I mean, you can easily code it yourself when you 
need it.

Ocaml can't yet automate this: C++ templates have
allowed this for some time. The C++ technology
isn't sound though. It works, usually, but you
can't be sure.

I'm no theorist, although I worked on a compiler
that implemented functorial polymorphism.
Perhaps real theorist can explain better what I'm
talking about.

John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net

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