Inherit interface from 2 interfaces

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Inherit interface from 2 interfaces

zaher dirkey
Can i do that?
type
  IIntf3 = interface(IIntf11, IIntf2)
....
  end;

Thanks in advance.
--
Zaher Dirkey

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Inherit interface from 2 interfaces

leledumbo
Administrator
Err... yes? Why don't you just try?
Reply | Threaded
Open this post in threaded view
|

Re: Inherit interface from 2 interfaces

zaher dirkey

On Wed, Apr 6, 2011 at 8:42 PM, leledumbo <[hidden email]> wrote:
Err... yes? Why don't you just try?


I tried before my post and failed, the idea is there any way enable it (like directive to add it), or it is implmented in the next versions of FPC, or only the answer is No :)


Regards

--
Zaher Dirkey

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Inherit interface from 2 interfaces

Juha Manninen
In reply to this post by zaher dirkey
Zaher Dirkey kirjoitti keskiviikko, 6. huhtikuuta 2011 19:37:04:
> Can i do that?
> type
>   IIntf3 = interface(IIntf11, IIntf2)
> ....
>   end;

No but you can do:
  type
  MyClass = class(IIntf11, IIntf2)
....
  end;


Juha
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Inherit interface from 2 interfaces

etrusco
In reply to this post by zaher dirkey
On Wed, Apr 6, 2011 at 1:37 PM, Zaher Dirkey <[hidden email]> wrote:

> Can i do that?
> type
>   IIntf3 = interface(IIntf11, IIntf2)
> ....
>   end;
>
> Thanks in advance.
> --
> Zaher Dirkey
>

For Corba interfaces, yes. Not for COM interfaces.
http://www.freepascal.org/docs-html/ref/refse39.html

-Flávio
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Inherit interface from 2 interfaces

zaher dirkey
2011/4/7 Flávio Etrusco <[hidden email]>
On Wed, Apr 6, 2011 at 1:37 PM, Zaher Dirkey <[hidden email]> wrote:
> Can i do that?
> type
>   IIntf3 = interface(IIntf11, IIntf2)
> ....
>   end;
>
> Thanks in advance.
> --
> Zaher Dirkey
>

For Corba interfaces, yes. Not for COM interfaces.
http://www.freepascal.org/docs-html/ref/refse39.html


I added {$INTERFACES CORBA} but same error ~Fatal: Syntax error, ")" expected but "," found~ in the line ~IIntf3 = interface(IIntf11, IIntf2)~

--
Zaher Dirkey

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Inherit interface from 2 interfaces

michael.vancanneyt


On Fri, 8 Apr 2011, Zaher Dirkey wrote:

> 2011/4/7 Flávio Etrusco <[hidden email]>
>
>> On Wed, Apr 6, 2011 at 1:37 PM, Zaher Dirkey <[hidden email]> wrote:
>>> Can i do that?
>>> type
>>>   IIntf3 = interface(IIntf11, IIntf2)
>>> ....
>>>   end;
>>>
>>> Thanks in advance.
>>> --
>>> Zaher Dirkey
>>>
>>
>> For Corba interfaces, yes. Not for COM interfaces.
>> http://www.freepascal.org/docs-html/ref/refse39.html
>>
>>
> I added {$INTERFACES CORBA} but same error ~Fatal: Syntax error, ")"
> expected but "," found~ in the line ~IIntf3 = interface(IIntf11, IIntf2)~
The whole idea of interfaces is to avoid multiple inheritance.

So you can never inherit from more than one interface.

Also not in CORBA interfaces. The mentioned page of the manual nowhere
states that this is possible. It just says that for CORBA interfaces,
the interface does not descend from IUnknown.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Inherit interface from 2 interfaces

etrusco
On Fri, Apr 8, 2011 at 6:16 AM,  <[hidden email]> wrote:

>
>
> On Fri, 8 Apr 2011, Zaher Dirkey wrote:
>
>> 2011/4/7 Flávio Etrusco <[hidden email]>
>>
>>> On Wed, Apr 6, 2011 at 1:37 PM, Zaher Dirkey <[hidden email]> wrote:
>>>>
>>>> Can i do that?
>>>> type
>>>>  IIntf3 = interface(IIntf11, IIntf2)
>>>> ....
>>>>  end;
>>>>
>>>> Thanks in advance.
>>>> --
>>>> Zaher Dirkey
>>>>
>>>
>>> For Corba interfaces, yes. Not for COM interfaces.
>>> http://www.freepascal.org/docs-html/ref/refse39.html
>>>
>>>
>> I added {$INTERFACES CORBA} but same error ~Fatal: Syntax error, ")"
>> expected but "," found~ in the line ~IIntf3 = interface(IIntf11, IIntf2)~
>
> The whole idea of interfaces is to avoid multiple inheritance.
>
> So you can never inherit from more than one interface.
>
> Also not in CORBA interfaces. The mentioned page of the manual nowhere
> states that this is possible. It just says that for CORBA interfaces,
> the interface does not descend from IUnknown.
>
> Michael.

My bad, I just answered based on the Delphi implementation.
I sent the link just for the sake of "reference".

Best regards,
Flávio
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Inherit interface from 2 interfaces

Andreas Dorn
In reply to this post by zaher dirkey
On Fri, 8 Apr 2011,michael.vancanneyt worte:
> The whole idea of interfaces is to avoid multiple inheritance.
>
Hm. I don't believe that.

One of the major points of interfaces is indeed to avoid the problems
of multiple class inheritance (diamond problems - i.e. problems caused by
conflicting implementations of a method in different ancestor classes).

But Interfaces themselves don't have an implementation, so those
diamond problems simply don't exist for them.

I don't think there's a good reason against multiple interface inheritance.

Not having multiple interface inheritance complicated certain situations
for myself.. forcing me to put runtime interface-casts into my code that
a compiler with multiple interface inheritance could have checked at compiletime.

--
Andreas


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Inherit interface from 2 interfaces

michael.vancanneyt


On Tue, 12 Apr 2011, Andreas Dorn wrote:

> On Fri, 8 Apr 2011,michael.vancanneyt worte:
>> The whole idea of interfaces is to avoid multiple inheritance.
>>
> Hm. I don't believe that.
>
> One of the major points of interfaces is indeed to avoid the problems
> of multiple class inheritance (diamond problems - i.e. problems caused by
> conflicting implementations of a method in different ancestor classes).
>
> But Interfaces themselves don't have an implementation, so those
> diamond problems simply don't exist for them.

Of course they do. If they inherit from 2 interfaces that have the same
method with a different signature, you have a problem.

InterfaceA = Interface
   Function IsValid : Integer;
end;

InterfaceB = Interface
   Function IsValid : String;
end;

How to define :

InterfaceC = Interface(InterfaceA,InterfaceB)

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Inherit interface from 2 interfaces

zaher dirkey


On Tue, Apr 12, 2011 at 11:42 AM, <[hidden email]> wrote:


On Tue, 12 Apr 2011, Andreas Dorn wrote:

On Fri, 8 Apr 2011,michael.vancanneyt worte:
The whole idea of interfaces is to avoid multiple inheritance.

Hm. I don't believe that.

One of the major points of interfaces is indeed to avoid the problems
of multiple class inheritance (diamond problems - i.e. problems caused by
conflicting implementations of a method in different ancestor classes).

But Interfaces themselves don't have an implementation, so those
diamond problems simply don't exist for them.

Of course they do. If they inherit from 2 interfaces that have the same
method with a different signature, you have a problem.

InterfaceA = Interface
 Function IsValid : Integer;
end;

InterfaceB = Interface
 Function IsValid : String;
end;

How to define :

InterfaceC = Interface(InterfaceA,InterfaceB)


I think, compile raise error duplicated methods, Same if inherit from one and add a method already exists in parent interface.

Regards

--
Zaher Dirkey

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal