From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id TAA06930 for caml-redistribution; Fri, 29 Oct 1999 19:21:21 +0200 (MET DST) 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 KAA11949 for ; Fri, 29 Oct 1999 10:56:51 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.8.7/8.8.7) with ESMTP id KAA09512; Fri, 29 Oct 1999 10:56:30 +0200 (MET DST) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA09378; Fri, 29 Oct 1999 10:56:29 +0200 (MET DST) Message-ID: <19991029105629.43047@pauillac.inria.fr> Date: Fri, 29 Oct 1999 10:56:29 +0200 From: Xavier Leroy To: Christopher Jeris , caml-list@inria.fr Subject: Re: [caml] Closures and efficiency References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.89.1 In-Reply-To: ; from Christopher Jeris on Tue, Oct 26, 1999 at 06:06:28PM -0400 Sender: weis > Here's the nub of my question. In a typical synth architecture there are > very many parameters which take values 0..127. If I had a function > > int_subrange_encoder: int -> int -> param_value -> bytestring > > which took the bounds of a subrange and generated an encoder function for > values of that subrange, and then in a voice-architecture description I > had a list of very many records each of which contained an entry > > int_subrange_encoder 0 127 > > would I suddenly have six million little closures, or would the compiler > do common-subexpression elimination on them ? As of now, the compiler doesn't do any common subexpression elimination. Notice that CSE over function applications is hard, because the compiler must make sure that the function has no side-effects. E.g. assume your function int_subrange_encoder prints something after receiving its first two arguments: let int_subrange_encoder lo hi = print_string "subrange_encoder was here!"; fun param -> ... Then, CSE would be incorrect. An easy thing to do is to let-bind the partial applications that occur frequently: let int_encoder = int_subrange_encoder 0 127 and then use "int_encoder" instead of "int_subrange_encoder 0 127" in your descriptions. Hope this helps, - Xavier Leroy