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 JAA02922; Fri, 30 Jan 2004 09:54:27 +0100 (MET) 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 JAA02754 for ; Fri, 30 Jan 2004 09:54:26 +0100 (MET) Received: from pop19.ucdavis.edu (pop19.ucdavis.edu [169.237.105.29]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id i0U8sPv29012 for ; Fri, 30 Jan 2004 09:54:25 +0100 (MET) Received: from manzanita ([128.120.141.214]) by pop19.ucdavis.edu (8.12.10/8.12.9/it-std-5.2.0) with SMTP id i0U8sNoV003374 for ; Fri, 30 Jan 2004 00:54:23 -0800 (PST) Received: by manzanita (sSMTP sendmail emulation); Fri, 30 Jan 2004 00:53:44 -0800 From: "Issac Trotts" Date: Fri, 30 Jan 2004 00:53:44 -0800 To: caml-list@inria.fr Subject: Re: [Caml-list] ocaml and concurrency Message-ID: <20040130085344.GA986@manzanita> Mail-Followup-To: ijtrotts@ucdavis.edu, caml-list@inria.fr References: <40199FE0.1070100@dcs.qmul.ac.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.4i X-Loop: caml-list@inria.fr X-Spam: no; 0.00; issac:01 trotts:01 ijtrotts:01 caml-list:01 2004:99 0600,:01 callbacks:01 callback:01 issac:01 trotts:01 redwood:99 ocaml:01 writting:01 int:01 int:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Fri, Jan 30, 2004 at 12:52:42AM -0600, Brian Hurt wrote: [snip] > > Technically, he's correct. What C doesn't have is partial function > application, which makes having functional types much less worthwhile- > it's impossible for a function type to also contain state. Which is why > when I do callbacks in C, I always include a void * context which is > passed (uninspected) to the callback routine. > > I mean, writting this function in C would be interesting to say the least: > > let summer ival = > let cval = ref ival in > let f x = cval := !cval + x; !cval in > f > ;; OK, maybe C doesn't support it, but it's easy to do this one in C++: #include class summer { int cval; public: summer(int ival): cval(ival) {} int operator()(int x) { cval += x; return cval; } }; int main() { summer s(3); assert(s(2)==5); assert(s(7)==12); return 0; } Issac [snip] -- Issac Trotts http://redwood.ucdavis.edu/~issac ------------------- 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