Xref: utzoo comp.lang.objective-c:237 comp.lang.misc:7526 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!uwm.edu!cs.utexas.edu!uunet!hsi!stpstn!lerman From: lerman@stpstn.UUCP (Ken Lerman) Newsgroups: comp.lang.objective-c,comp.lang.misc Subject: Re: Optional static typing limits Message-ID: <6785@stpstn.UUCP> Date: 18 Apr 91 11:52:12 GMT References: Reply-To: lerman@stpstn.UUCP (Ken Lerman) Organization: The Stepstone Corporation, Sandy Hook, CT 06482 Lines: 52 In article liberte@ncsa.uiuc.edu (Daniel LaLiberte) writes: |> |>----- file A.h ---------- |>// interface of class A |> |>#include "B.h" // A needs to include B's interface |> |>@interface A:Object |>{ |> B *b; // instance variable b is a pointer to B |> ... |>} |> |>----- file B.h ---------- |>// interface of class B |> |>#include "A.h" // B needs to include A's interface <-- *ERROR* |> |>@interface B:Object |>{ |> A *a; // instance variable a is a pointer to A |> ... |>} |> |>Dan LaLiberte |>National Center for Supercomputing Applications |>liberte@ncsa.uiuc.edu A (not very nice) way of handling this in Stepstone's Objective-C compiler is to write struct __objcA *a and struct __objcB *b to declare the instance variables. A better way would be for the compiler to permit @interface A {} @end to be an incomplete definition of class F which could be completed later on. A further deficiency of Objective-C regarding automatic and static instances of objects (those that are declared Object foo, instead of Object *foo) is that the compiler doesn't automatically call an initializer for them so that only the isa pointer is set. This implies that the writer of the class must know that it will be used this way. I personally don't use them and suggest that others avoid them, also. Ken Disclaimer: In case you haven't noticed, I work for Stepstone. I don't speak for them in this matter. lerman@stepstone.com