Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: 2003-08-06 (18:12)
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, 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.


To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: