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 XAA25701; Tue, 18 May 2004 23:08:05 +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 XAA25702 for ; Tue, 18 May 2004 23:08:04 +0200 (MET DST) Received: from calmail-cl.berkeley.edu (mailfarm.Berkeley.EDU [128.32.61.106]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i4IL82SH023019 for ; Tue, 18 May 2004 23:08:03 +0200 Received: from [64.162.212.212] (HELO tallman.kefka.frap.net) by calmail-cl.berkeley.edu (CommuniGate Pro SMTP 4.1.8) with SMTP id 29108920; Tue, 18 May 2004 13:33:36 -0700 Received: by tallman.kefka.frap.net (sSMTP sendmail emulation); Tue, 18 May 2004 13:31:26 -0700 Date: Tue, 18 May 2004 13:31:26 -0700 From: Kenneth Knowles To: SWAMPY Cc: caml-list Subject: Re: [Caml-list] Functional critical section Message-ID: <20040518203126.GA1047@tallman.kefka.frap.net> References: <1084869517.19838.409.camel@pelican.wigram> <20040518090635.GA6918@bourg.inria.fr> <1084875941.19838.446.camel@pelican.wigram> <20040518121147.GA20094@redhat.com> <1084910535.30471.49.camel@ice.gerd-stolpmann.de> <006801c43d14$61edef40$10015c0a@word> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <006801c43d14$61edef40$10015c0a@word> User-Agent: Mutt/1.5.6i X-Miltered: at concorde with ID 40AA7B32.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; knowles:99 caml-list:01 camlp:01 lablgl:01 motivations:01 camlp:01 wwwtcs:01 tews:01 htmlman-:01 3.07:01 2004:99 0400,:01 expr:01 expr:01 bug:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk With Camlp4 you may be able to do this via pre-processing. Otherwise you could do it with lazy evaluation, supported by the Lazy module in the standard library. An inefficient lazy evaluation can be had be just adding an additional unit argument to your function. (lablGL does something like this, though I'm not sure of their motivations) http://caml.inria.fr/camlp4/manual/ http://wwwtcs.inf.tu-dresden.de/~tews/htmlman-3.07/libref/Lazy.html Kenn On Tue, May 18, 2004 at 04:10:44PM -0400, SWAMPY wrote: > Hello! > > I'm very new to ocaml, and I'm trying to figure out how > to do something that may or may not actually be possible. > Any suggestions? > > I'd like to write > > > > as an expression, and have this evaluate first > evaluating fixed expression A, and then after evaluting > evaluate fixed expression B. > Then, I could do something like: > > critical (threadsafeFunction arg1 arg2 arg3) > > and have this do the equivalent of > > Mutex.lock someMutex; let tmp = threadsafeFunction arg1 > arg2 arg3; Mutex.unlock someMutex; tmp;; > > Is this sort of thing possible? In general I'm > interested in techniques I could use to wrap > imperative-biased parts of the library to more functional > constructs. > > Cheers, > > David J. Trombley > > ------------------- > 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 ------------------- 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