Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Unix.kill on Win32
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: David Brown <caml-list@d...>
Subject: Re: [Caml-list] static class member....
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