Now I am really concerned. So are you implying that the use of "this" in a constructor is illegal? That would be a very bad place to end up as far as I am concerned. I absolutely believe that "this" is valid during construction. Given that, it is indistinguishable from *inside* the constructor whether the constructor is a static method or not. I absolutely agree that from the *caller* side it looks like a static method. But it really isn't and I believe that it would be incredibly misleading to describe it as such. Gord. jonathan.bromley@doulos.com wrote: > [constructors] >> are not invoked using a handle because their invocation allocates >> the object that they use. But regardless of how they are invoked, they >> are inherently not static. Their purpose is to construct the object, >> which they cannot do without access to the object. > > Agreed, but... > >> They have to be passed >> a 'this' handle (which is the handle for the allocated object) so that >> they can initialize the nonstatic members of the object. > > I think there's another way of thinking about it that makes > rather more sense to me. > > When I call new() explicitly, I most certainly don't think of > it being passed "this" because "this" doesn't exist at the > time of the call. Instead, imagine that the constructor > truly *is* static, but has "this" as an implicit local > variable that is implicitly used as a prefix to any mention > of class members within the body of new(). > > I'm very aware that this description is torturing the > meaning of "this", but I still maintain that any call > to new() looks like a static method call; there is no > meaningful "this" at the time of the call, and so the > implicit "this" argument that is passed to non-static > methods can't happen. And, indeed, this is perhaps > the root of some of the problems with super.new(); > at the time of the call to super.new(), "super" has > already been allocated - making that call to new() > very different from a user's call to the base class's > constructor. > > Whatever, we have to accept that new() is strange and > special, so we can make strange and special rules for it. -- -------------------------------------------------------------------- Gordon Vreugdenhil 503-685-0808 Model Technology (Mentor Graphics) gordonv@model.com -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.Received on Fri May 8 07:58:45 2009
This archive was generated by hypermail 2.1.8 : Fri May 08 2009 - 07:59:28 PDT