Browse thread
[Caml-list] [ANN] The Missing Library
-
John Goerzen
-
Kenneth Knowles
- Alexander V. Voinov
-
John Goerzen
-
Maxence Guesdon
-
John Goerzen
- Maxence Guesdon
-
John Goerzen
-
Alain.Frisch@e...
-
John Goerzen
-
Alain.Frisch@e...
-
Nicolas Cannasse
-
Yamagata Yoriyuki
- Gerd Stolpmann
-
Nicolas Cannasse
-
Yamagata Yoriyuki
- Jacques GARRIGUE
- Nicolas Cannasse
-
Yamagata Yoriyuki
-
Yamagata Yoriyuki
-
Nicolas Cannasse
- oliver@f...
-
Alain.Frisch@e...
-
John Goerzen
- Henri DF
- Shawn Wagner
- james woodyatt
-
Alain.Frisch@e...
- Basile STARYNKEVITCH
-
John Goerzen
- Kenneth Knowles
- Florian Hars
-
Maxence Guesdon
- Eric C. Cooper
-
Kenneth Knowles
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2004-04-29 (03:01) |
From: | skaller <skaller@u...> |
Subject: | Re: [Caml-list] [ANN] The Missing Library |
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