discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

forward references


From: Aurelien
Subject: forward references
Date: Tue, 28 Aug 2001 18:44:36 +0200

Hi,

I've made my mind ! I'm going to at least try to port JXTA to Objective-c. I'm in the process of translating the java sources to Objective-C skeletons. I have now about a hundred classes automatically generated from a simple script I wrote. The classes and protocols have dummy methods, but I've found that the two languages bear incredible similarity. Anyway, the generated source cannot be compiled yet. When I have successfully set up a development environment with GNUstep/KDevelop (I'm working hard on this with the very kind help of Richard Dale), I'll use this as my favorite platform. Anyway, in the mean time, I'm using Apple's Project Builder. I only plan to use Foundation classes for this project anyway.

The problem currently at hand is as follows:

several classes use PeerGroup objects. When compiling those classes, the compiler comes to the point when it must compile the PeerGroup class. Anyway, PeerGroup references other classes still, and hence the compiler doesn't stop there and tries to compile the classes PeerGroup refers to. But these classes also use PeerGroup objects... PeerGroup isn't exactly a class actually. It is really a protocol. And objects which PeerGroup uses are also protocols as far as I'm concerned.

This classic problem isn't an issue when compiling a java program. That isn't true for Objective-C !
Somewhere in "Object-Oriented Programming and the Objective-C Language", I found the following:

In such a situation, circularity results and neither file will compile correctly. To break this recursive cycle, you must use the @protocol directive to make a forward reference to the needed protocol instead of importing the interface file where the protocol is defined. The following code excerpt illustrates how you would do this:

@protocol B;

@protocol A
- foo:(id <B>)anObject;
@end


But apparently the '@protocol B;' part isn't recognized by the compiler, which sees it as a protocol *declaration*, which is not what I want him to understand !

Does somebody have a clue ?

thx everyone !

Aurélien
reply via email to

[Prev in Thread] Current Thread [Next in Thread]