From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id OAA01393; Wed, 28 Apr 2004 14:13:40 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id OAA01370 for ; Wed, 28 Apr 2004 14:13:39 +0200 (MET DST) Received: from smtp1.adl2.internode.on.net (smtp1.adl2.internode.on.net [203.16.214.181]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i3SCDajq000531 for ; Wed, 28 Apr 2004 14:13:37 +0200 Received: from [192.168.1.200] (ppp119-113.lns1.syd2.internode.on.net [150.101.119.113]) by smtp1.adl2.internode.on.net (8.12.9/8.12.9) with ESMTP id i3SC9bZq039723; Wed, 28 Apr 2004 21:39:39 +0930 (CST) Subject: Re: [Caml-list] [ANN] The Missing Library From: skaller Reply-To: skaller@users.sourceforge.net To: "Yaron M. Minsky" Cc: Brian Hurt , Martin Berger , The Caml Trade In-Reply-To: <1083151902.29774.18.camel@localhost.localdomain> References: <1083140676.9537.831.camel@pelican.wigram> <1083151902.29774.18.camel@localhost.localdomain> Content-Type: text/plain Message-Id: <1083154175.9537.944.camel@pelican.wigram> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 28 Apr 2004 22:09:37 +1000 Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 sourceforge:01 2004:99 yaron:01 minsky:01 2004:99 iterator:01 iterator:01 abstraction:01 functorial:01 expressive:01 'map':01 polynomial:01 'map':01 polynomial:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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