<p>Am 15.04.2016 08:46 schrieb "Ryan Joseph" <<a href="mailto:ryan@thealchemistguild.com">ryan@thealchemistguild.com</a>>:<br>
> Does this look like more work than using $includes? Maybe I need to seriously considering reorganizing my projects to work like this but it just feels wrong for some reason.<br>
><br>
> =====================<br>
><br>
> unit Globals;<br>
> interface<br>
><br>
> type<br>
> HClassB = 'TClassB'; // declare a hint to the class name<br>
><br>
> implementation<br>
> end.<br>
><br>
> =====================<br>
><br>
> unit ClassB;<br>
> interface<br>
> uses<br>
> ClassA;<br>
><br>
> type<br>
> TClassB = class<br>
> procedure DoSomething (sender: TClassA);<br>
> end;<br>
><br>
> implementation<br>
><br>
> procedure TClassB.DoSomething (sender: TClassA);<br>
> begin<br>
> // full access to TClassA<br>
> end;<br>
><br>
> end.<br>
><br>
> =====================<br>
><br>
> unit ClassA;<br>
> interface<br>
> uses<br>
> Globals;<br>
><br>
> type<br>
> TClassA = class<br>
> // The interface section can't know about TClassB so we declare a<br>
> // class name hint from Globals.pas (HClassB) and assign the paramter with it<br>
> // using the "hint" syntax<br>
> procedure SetValue (value: TObject[HClassB]);<br>
> end;<br>
><br>
> implementation<br>
><br>
> // use ClassB now so hints evaluate<br>
> uses<br>
> ClassB;<br>
><br>
> procedure TClassA.SetValue (value: TObject[HClassB]);<br>
> begin<br>
> // behind the scenes the compiler (or preparser if FPC has one) replaces the text "TObject[HClassB]" to “TClassB" or throws an error if the identifier TClassB is not found<br>
> value.DoSomething(self);<br>
> end;<br>
><br>
> end.</p>
<p>*shudders* Before we introduce such syntax I'd prefer to get the formal class types that were added for Objective Pascal working with Object Pascal as well (which would be exactly what you want just with a more sane syntax).</p>
<p>But again: you're currently fighting against the language. Use interfaces and abstract classes and overthink your dependencies and design. </p>
<p>Regards,<br>
Sven</p>