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 FAA11482; Thu, 29 Apr 2004 05:01:02 +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 FAA11457 for ; Thu, 29 Apr 2004 05:01:00 +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 i3T30vjq008030 for ; Thu, 29 Apr 2004 05:00:59 +0200 Received: from [192.168.1.200] (ppp114-169.lns1.syd3.internode.on.net [150.101.114.169]) by smtp1.adl2.internode.on.net (8.12.9/8.12.9) with ESMTP id i3T30pZq031842; Thu, 29 Apr 2004 12:30:53 +0930 (CST) Subject: Re: [Caml-list] [ANN] The Missing Library From: skaller Reply-To: skaller@users.sourceforge.net To: Jon Harrop Cc: caml-list In-Reply-To: <200404290256.24399.jdh30@cam.ac.uk> References: <200404281942.05371.jdh30@cam.ac.uk> <1083200626.9537.1199.camel@pelican.wigram> <200404290256.24399.jdh30@cam.ac.uk> Content-Type: text/plain Message-Id: <1083207649.9537.1250.camel@pelican.wigram> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 29 Apr 2004 13:00:51 +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 implemented:01 implemented:01 'read:01 inverted:01 supplier:99 supplier:99 sux:99 threads:01 coroutines:01 mechanically:01 callback:01 gui:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Thu, 2004-04-29 at 11:56, Jon Harrop wrote: > > Can you give me a simple example where you are forced to use mutable state? Implement List.rev by defining "revit" below: List.iter revit lst Note: you have also implemented something more. You have also implemented: Array.to_rev_list Array.iter revit arr Your revit function is polyadic with respect to the input data structure, the XXXX.iter function is used to factor that out. This property is also shared by the 'read/pull/control inverted/thread-like/ continuation passing' solution. In fact, the two solutions are dual. They do the same job. For "full inversion" you need to also invert the HOF. For example here is the traditional master List.iter: let iter f = function | h::t -> f h; iter f t | [] ->() This is the desirable form. This is an algorithm that writes its output: it is the caller. The inverse is a supplier of list elements: let make_supplier lst = let lst = ref lst in let get () = function | h :: t -> lst :=t; h | [] -> raise Not_found in get This is hard to write but allows the client routine to get() elements. Traditionally, algorithms had to be factored so one of the cooperating pair of routines had to be unnatural: one had to be master, and the other slave. This sux. You want BOTH to be masters. You can clearly do that with two threads and a monitor object (more precisely, coroutines). Felix control inverts arbitrary procedural code mechanically: that is, you write code that reads data and it is translated into a callback. Wouldn't you rather program an *active* agent for your complex GUI widgets that a passive callback driven one? -- 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