[fpc-pascal] problems with CORBA interfaces having no base type

Sven Barth pascaldragon at googlemail.com
Tue Sep 20 10:07:58 CEST 2011

Am 20.09.2011 09:47, schrieb Graeme Geldenhuys:
>> Because IInterface is designated as a COM-interface and you can't
>> descend a CORBA-interface from a COM-interface or vice-versa.
> This is not what I meant. Just like the compiler has compiler modes, why
> can't the {$interfaces corba} change the "mode" of IInterface. The name
> also says it's a "generic interface type", so maybe the compiler could
> that inject the following
>    IInterface = interface
>    end;
> ...overriding (or better, hiding) the old COM declaration of...
>    IInterface = IIUnkown
> So then in CORBA style interfaces, the following two declarations mean
> the same thing (just like they would if I used COM style interfaces)
> {$interfaces corba}
> ...
>    ISubject = interface
>    end;
>    ISubject = interface(IInterface)
>    end;
> Just like String can mean AnsiString or ShortString, based on a compiler
> switch.

1. Changing the meaning of IInterface based on $interfaces is not 
possible, because IInterface is located in System unit.

2. Hiding IInterface with a CORBA-based base type is a nice idea at the 
first glance, but you'll get trouble later, because the base object will 
be defined in the same unit as the derived symbol:

Imagine you have two units where both declare a CORBA-interface without 
a parent. Then both units will contain a definition of the basetype. Now 
you have a third unit that uses those two units and defines an interface 
that derives from one of the two previous interfaces. This interface 
won't be compatible then with the other one, from which you didn't derive.

So there are only two other possibilities left:
1. Add a new RTL unit that defines a base interface for CORBA and 
include that if {$interface corba} is encountered. Problem: I don't know 
whether $interface is a local or unit global switch (someone else needs 
to answer this).

2. Add a base type with a different name (e.g. ICORBAInterface) in the 
System unit and use that as base type.

I personally would suggest the latter.


More information about the fpc-pascal mailing list