From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id pBUBf9sU019323 for ; Fri, 30 Dec 2011 12:41:09 +0100 X-IronPort-AV: E=Sophos;i="4.71,432,1320620400"; d="scan'208";a="137275169" Received: from chercheur-120.msr-inria.inria.fr (HELO [10.0.1.5]) ([193.55.250.120]) by mail1-relais-roc.national.inria.fr with ESMTP/TLS/AES128-SHA; 30 Dec 2011 12:41:04 +0100 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Apple Message framework v1084) From: Damien Doligez In-Reply-To: <4EF47360.2010302@inria.fr> Date: Fri, 30 Dec 2011 12:41:04 +0100 Content-Transfer-Encoding: 7bit Message-Id: <98C4A68D-2A7C-415E-BD0D-AD5ECAE7D238@inria.fr> References: <20111222212429.GA8156@yeeloong.happyleptic.org> <874nws89sz.fsf@inria.fr> <20111223120413.GA4433@ccellier.rd.securactive.lan> <4EF47360.2010302@inria.fr> To: caml users X-Mailer: Apple Mail (2.1084) Subject: Re: [Caml-list] Bless me Father, for I have used Obj.magic On 2011-12-23, at 13:26, Fabrice Le Fessant wrote: > On 12/23/2011 01:04 PM, rixed@happyleptic.org wrote: >> No you are right, once eta-epxanded the compiler accepted the code. >> I wonder what difference it makes in the generated code, if any. >> Thank you very much for the tip! > > The difference is that the function is evaluated everytime you want to > access the value. If the function is cheap and has no side-effect, it is > perfectly fine, but if it is not the case, the cost will be much higher. On the other hand, in the example shown by rixed the function expects two arguments, so eta-expansion might even be more efficient because you avoid going through the partial application machinery. -- Damien