From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA00365 for caml-red; Tue, 21 Nov 2000 10:36:56 +0100 (MET) 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 KAA16572 for ; Tue, 21 Nov 2000 10:36:39 +0100 (MET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id eAL9ac526637; Tue, 21 Nov 2000 10:36:38 +0100 (MET) Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA02218; Tue, 21 Nov 2000 10:36:38 +0100 (MET) From: Pierre Weis Message-Id: <200011210936.KAA02218@pauillac.inria.fr> Subject: Re: unwind-protect? In-Reply-To: <200011171401.PAA0000024608@beaune.inria.fr> from Damien Doligez at "Nov 17, 100 03:01:34 pm" To: Damien.Doligez@inria.fr (Damien Doligez) Date: Tue, 21 Nov 2000 10:36:38 +0100 (MET) Cc: caml-list@inria.fr X-Mailer: ELM [version 2.4ME+ PL28 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: weis@pauillac.inria.fr > >From: Pierre Weis > > >Here, polymorphism, curryfication, and specialization are shining, > >since you juste have to add one in_* functional application before an > >actual call to any function f to obtain a specialized evaluation > >context for f. For instance: > > >let in_tmp f arg = in_directory "/tmp" f arg;; > > Actually, currying gets in the way in this case (as it often does). > If f takes two arguments, then "in_tmp f x y" will not work as > expected, but the type-checker will not find the error. > > -- Damien Right, you have to know that this in_* functions protect the last application of a function. Hence to apply a curried function you need parens to partially apply the function, as in_tmp (f x y) z. Alternatively, you can define your n-ary functions as having tupled arguments and write in_tmp f (x, y, z) (then the typechecker will find the ``arity'' errors). If you had functions with specific arity built-in in the langage, you would have to define multiple versions of the protect functions, one for each arity, which is not so appealing... Pierre Weis INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://cristal.inria.fr/~weis/