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: | -- (:) |
| From: | Jon Harrop <jdh30@c...> |
| Subject: | Re: [Caml-list] [ANN] The Missing Library |
On Thursday 29 April 2004 4:00 am, skaller wrote: > 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? > ... > 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 But can't this be implemented without mutable state as: let make_supplier lst = let rec get lst () = match lst with [] -> raise Not_found | h::t -> (h, fun () -> get t ()) in get lst so it returns the next element and a function to "supply" the rest. > ... > let iter f = function > | h::t -> f h; iter f t > | [] ->() > > This is the desirable form. Why is that desirable? To me, it looks as though this form is necessarily more verbose and, therefore, undesirable. > 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. Is mutual recursion not an example of having two "master" functions. > Felix control inverts arbitrary procedural code > mechanically: that is, you write code that reads > data and it is translated into a callback. What is your favourite example of this code morphing being useful? > Wouldn't you rather program an *active* agent > for your complex GUI widgets that a passive callback > driven one? I don't know. I just brush my hands over the keyboard and programs come out. :-) Cheers, Jon. ------------------- 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