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 RAA10364; Thu, 12 Apr 2001 17:22:41 +0200 (MET DST) 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 RAA10384 for ; Thu, 12 Apr 2001 17:22:40 +0200 (MET DST) Received: from postfix2-2.free.fr (postfix2-2.free.fr [213.228.0.140]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f3CFMeT25160 for ; Thu, 12 Apr 2001 17:22:40 +0200 (MET DST) Received: from sbuilders.com (paris11-nas9-38-177.dial.proxad.net [212.27.38.177]) by postfix2-2.free.fr (Postfix) with ESMTP id A5A0D6B77F; Thu, 12 Apr 2001 17:22:38 +0200 (CEST) Message-ID: <3AD5C804.B2349D0D@sbuilders.com> Date: Thu, 12 Apr 2001 17:21:40 +0200 From: Maxence Guesdon Reply-To: max@sbuilders.com X-Mailer: Mozilla 4.75 [fr] (X11; U; Linux 2.2.16-22 i686) X-Accept-Language: fr, en MIME-Version: 1.0 To: Mattias Waldau Cc: caml-list@inria.fr Subject: Re: [Caml-list] How do I define prog1? References: Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Mattias Waldau a écrit : > > I would like to define a (prog1 a b) which first evaluates a, then b, and > returns the > value of a. (Would be nice if I could have arbitrary number of args.) > > I defined it as > > let prog1 a b = a > > Works well in compiled code, first evaluates a, then b. > However bytecode first evaluates b, then a. > > In this cases, call-by-name would be very nice. > > One obvious solution is to write > > let temp = a in > b; > temp > > but that is much too clumsy. > > /mattias > > ------------------- If you want prog1 to evaluate a then b, you can do let prog1 fa fb = let a = fa () in let _ = fb() in a then call prog1 this way : prog1 (fun () -> a) (fun () -> b); -- Maxence ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr