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 EAA08143; Thu, 29 Apr 2004 04:00:32 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id EAA08144 for ; Thu, 29 Apr 2004 04:00:30 +0200 (MET DST) Received: from ptb-relay03.plus.net (ptb-relay03.plus.net [212.159.14.214]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i3T20TYM004739 for ; Thu, 29 Apr 2004 04:00:29 +0200 Received: from [80.229.56.224] (helo=chetara) by ptb-relay03.plus.net with esmtp (Exim) id 1BJ0qj-000AKy-B6 for caml-list@inria.fr; Thu, 29 Apr 2004 02:00:29 +0000 From: Jon Harrop Organization: University of Cambridge To: caml-list Subject: Re: [Caml-list] [ANN] The Missing Library Date: Thu, 29 Apr 2004 02:56:24 +0100 User-Agent: KMail/1.5.4 References: <200404281942.05371.jdh30@cam.ac.uk> <1083200626.9537.1199.camel@pelican.wigram> In-Reply-To: <1083200626.9537.1199.camel@pelican.wigram> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200404290256.24399.jdh30@cam.ac.uk> X-Miltered: at concorde by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 2004:99 inverted:01 helper:01 helper:01 inverted:01 generic:01 recursion:01 callback:01 model:01 bindings:01 mutable:01 mutable:01 rec:01 match:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Thursday 29 April 2004 2:03 am, skaller wrote: > You are missing the point. I sure am. ;-) > Neither solution control inverts. Does that mean that my function is being called by map, rather than having my function explicitly fetch the next element? So, is this "control inverted": let print string_of l = let rec helper l = match l with [] -> "" | h::[] -> "; "^(string_of h)^"]" | h::t -> "; "^(string_of h)^(helper t) in print_string (match l with [] -> "" | h::t -> "["^(string_of h)^(helper t)) > So they're both weak. By this, do you mean that "control inverted" functions are more generic? If the above function is control inverted, in what way is it better than my original? > In the control inverted solution > you aren't not called with some state, Is that the same as "you are called with some state"? > you do the calling > so you can use for example let/bindings and recursion > to maintain state "functionally": you cannot do that > with the callback driven model, you're forced to use > mutable state. Can you give me a simple example where you are forced to use mutable state? 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