[fpc-pascal] A better way?

Tony Whyman tony.whyman at mccallumwhyman.com
Fri Apr 15 12:34:16 CEST 2016

Just remembered, FPC also supports macros - see 

I haven't tested it, but you should be able to do


{$DEFINE aClassBObject:=TClassB(FClassBObject) }

and then use aClassBObject instead of the coercion.

On 15/04/16 11:13, Tony Whyman wrote:
> In the end though this is just a "what's in a name? A rose by any 
> other name would smell as sweet" debate. No matter how you approach 
> the problem, you have to have an identifier for the other class when 
> you reference its methods and properties. If you don't want to declare 
> two mutually referential classes in the same unit, then one of them 
> (but only one) has to use some technique to avoid circular references. 
> Type casting is a simple technique and you either have to coerce each 
> use (think of TClassB(FObject) as just being a longer name for the 
> same thing) or declare an alias of the correct type - a "With" 
> statement can also be your friend here. 

More information about the fpc-pascal mailing list