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 WAA19831; Tue, 6 Mar 2001 22:40:12 +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 WAA19497 for ; Tue, 6 Mar 2001 22:40:11 +0100 (MET) Received: from mail.mimuw.edu.pl (pm141.warszawa.cvx.ppp.tpnet.pl [213.76.108.141]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f26Ldwb06974 for ; Tue, 6 Mar 2001 22:39:58 +0100 (MET) Received: (from news@localhost) by mail.mimuw.edu.pl (PLD/8.9.3) id WAA00944 for caml-list@inria.fr; Tue, 6 Mar 2001 22:39:57 +0100 X-Authentication-Warning: qrnik.zagroda: news set sender to qrczak@knm.org.pl (Marcin 'Qrczak' Kowalczyk) using -f From: qrczak@knm.org.pl (Marcin 'Qrczak' Kowalczyk) Subject: Re: [Caml-list] currying... Date: 6 Mar 2001 21:39:54 GMT Organization: Klub Nieszkodliwych =?iso-8859-2?Q?Manjak=F3w?= Message-ID: References: <4.3.2.7.2.20010306012957.00c7cf00@shell16.ba.best.com> <4.3.2.7.2.20010306012957.00c7cf00@shell16.ba.best.com> <4.3.2.7.2.20010306093019.00e181f0@shell16.ba.best.com> <4.3.2.7.2.20010306120843.037813b0@shell16.ba.best.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2 Content-Transfer-Encoding: 8bit X-Trace: qrnik.zagroda 983914794 942 192.168.0.1 (6 Mar 2001 21:39:54 GMT) X-Complaints-To: news@qrnik.zagroda NNTP-Posting-Date: 6 Mar 2001 21:39:54 GMT User-Agent: slrn/0.9.6.3 (Linux) To: caml-list@inria.fr Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Tue, 06 Mar 2001 12:14:35 -0800, Chris Hecker pisze: > But that's not true if I'm trying to proxy a caml function with > a c function. I need to know where the "return value" starts. There is no such concept. The same function can have different physical arity depending on how it was compiled - it doesn't correspond to anything meaningful in the source. Functions present the same interface no matter what their physical arity is. From the C level too. A library which has different behavior depending on the physical arity of functions it works on is broken. The programmer has no control how functions are compiled - it's the compiler's business. > >AFAIK this internal "uncurrying" is limited to a constant (up to 5 > >arguments or something). Above that functions are really implemented > >as functions returning functions, in groups of 5 arguments. > > That can't be true at the lowest level, Why? "Uncurrying" anything at all is an optimization. A straightforward implementation would just apply arguments one at a time, allocating a closure at each step. Since currying is so common and there is so much performance gain in treating it specially, OCaml does the trouble of applying multiple arguments at once when it can. This requires a more complex calling protocol, but is worth the effort. > unless caml does some really stoked partial evaluation analysis. I'm not sure what you mean. > If I write a function that takes 10 parms and uses them in a > nonlinear way then I don't think you can factor it into 2 5-parm > functions. It happens under the cover. From OCaml's point of view you can treat is a function which returns a function which returns a function etc. - 10 times. Or a curried 10-argument function. The point of split is an implementation detail. It has no effect on the semantics. No code should rely on where it is, unless it hides this under its cover too and presents a unified interface to the outside. Do you really have a case where you can use this fact to enable better performance? I understood that you want to use the distinction to decide to which C type an OCaml type corresponds. This is broken. An OCaml type of a binary function, and of an unary function returning an unary function, is the same. > Unless you're saying it just substitutes them into the function, > but then it would have to build a whole new function every time > your partially applied. Indeed you allocate a new object when you partially apply a function. -- __("< Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZASTĘPCZA QRCZAK ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr