PDA

View Full Version : recursive units?



noeska
22-05-2007, 08:53 PM
For an component i am writing i ran into the following situation:

tclass in uclass.pas is depend on:
tclasslist in uclasslist.pas but that also needs tclass1 as
tclasslist is an list of tclass and
tclass contains an tclasslist.

Now turbo delphi for win32 hapily takes this and it works, but i believe in previous versions of delphi this may not work as you would get an circular reference. Should i worry about this?

savage
22-05-2007, 09:09 PM
You will only get circular referencing if everythiing appears in your interface section. If they are correctly set up in interface and implementation sections, I think you should be fine.

Does this make sense?

M109uk
22-05-2007, 09:10 PM
Im not sure myself, but i have delphi 2006 and used to 2005 and i know that they hated circular references :( unit1.pas uses unit2.pas, unit2.pas uses unit3.pas, and unit3.pas uses unit1.pas always broke down..

noeska
22-05-2007, 10:03 PM
You will only get circular referencing if everythiing appears in your interface section. If they are correctly set up in interface and implementation sections, I think you should be fine.

Does this make sense?
yes.

my mistake in writing the tclass contains an tclasslist part as i did not have it i have a:
FParent := TSkeleton(owner).GetBoneByName(FParentName);
and the uses for that was in the implementation. Lucky me.

The situation from my initial post can only be solved by putting both classes in the same unit then? As to declare tclasslist in tclass i need to have the second unit in the interface of the first an for tclass in tclasslist i need to have the first unit in the interface part.

Angelo
25-06-2007, 06:35 PM
I'm not sure whether this topic is still relevant or not.
But just to clear it up:

Yes it does make sense where you put your uses.
Example:

You got unit1, which uses unit2.
Put unit2 under your interface uses claw.
Unit 2 also uses unit1 (for example for the form), put unit2 under your implementation uses claw.