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 UAA32220; Wed, 6 Aug 2003 20:12:08 +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 UAA30299 for ; Wed, 6 Aug 2003 20:11:57 +0200 (MET DST) Received: from opus.davidb.org (66-75-152-1.san.rr.com [66.75.152.1]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h76IBsT16539 for ; Wed, 6 Aug 2003 20:11:55 +0200 (MET DST) Received: from davidb by opus.davidb.org with local (Exim 3.31 #1 (Debian)) id 19kSlI-00081N-00; Wed, 06 Aug 2003 11:11:48 -0700 Date: Wed, 6 Aug 2003 11:11:48 -0700 From: David Brown To: Richard Jones Cc: brogoff@speakeasy.net, David Brown , Vovka , "caml-list@inria.fr" Subject: Re: [Caml-list] static class member.... Message-ID: <20030806181148.GA30782@davidb.org> References: <20030806151051.GB29704@redhat.com> <20030806174330.GA30804@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030806174330.GA30804@redhat.com> User-Agent: Mutt/1.5.4i X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 brogoff:01 bug:01 compiler:01 ocaml:01 0700,:01 speakeasy:01 06,:02 objects:02 module:03 behaves:03 dave:03 classes:03 wrote:03 argument:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wed, Aug 06, 2003 at 06:43:30PM +0100, Richard Jones wrote: > On Wed, Aug 06, 2003 at 09:12:24AM -0700, brogoff@speakeasy.net wrote: > > Yes, it says in the language introduction (the part on objects) > > > > Let-bindings within class definitions are evaluated before the object > > is constructed > > Well I take it back. And I must admit that I always have used > let-bindings as if they are local to the instance. > > The question though is why does my example work? Is this a bug > in the compiler? It works because there are no arguments to the class. In that case, the class is evaluated once, when that part of the module is evaluated. If there is an argument to the class, it behaves as if the entire class definition were wrapped in a function definition. Therefore it can't evaluate things inside until the function is fully evaluated. Creating objects of classes is an unusual thing in ocaml, since it is like a function application of zero arguments. What's scary is that I've been bitten by this several times, and still manage to forget it. Dave ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners