Recent

Author Topic: Interfaces without CORBA, COM  (Read 2166 times)

XiJinping

  • New member
  • *
  • Posts: 9
Interfaces without CORBA, COM
« on: September 12, 2019, 07:30:32 am »
I tried interfaces in Free Pascal (delphi mode). And it seems that to compile a code with interfaces, I need to use directive
Code: Pascal  [Select][+][-]
  1. {$interfaces corba}
(or com, I suppose). As I understand, these interfaces add runtime support of CORBA (or COM) IInterface. But is there any way to use simple interface like in any other OOP language without CORBA, COM and similar which will be ordinal, existing at compile time only classical interface?

PascalDragon

  • Hero Member
  • *****
  • Posts: 5763
  • Compiler Developer
Re: Interfaces without CORBA, COM
« Reply #1 on: September 12, 2019, 09:11:58 am »
The naming of {$interfaces com} and {$interfaces corba} is a bit misleading. The main difference is that if {$interfaces com} is set then an interface inherits from IUnknown which provides the methods _AddRef, _Release and QueryInterface which in turn allows the compiler to provide automatic reference counting for such interfaces as well as support for the as and is operators. It's suggested to inherit from TInterfacedObject in such cases (though in no way required). "CORBA" interfaces on the other hand are raw interfaces. They don't inherit from anything and they don't provide reference counting, so you yourself are responsible that the class instance implementing the interfaces is freed at the end.

XiJinping

  • New member
  • *
  • Posts: 9
Re: Interfaces without CORBA, COM
« Reply #2 on: September 12, 2019, 09:52:03 am »
So is it a correct suggestion: CORBA interfaces are the same as plain usual interfaces in other languages and they have not any runtime overhead to support CORBA? I mean something like C++ "interfaces" (with pure virtual functions)...

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11947
  • FPC developer.
Re: Interfaces without CORBA, COM
« Reply #3 on: September 12, 2019, 11:09:47 am »
Indeed. When interfaces were added, the COM IUnknown dependency was seen as a potential portability problem, so a more base interface type was added.

As Corba was seen as a potential substitute for COM on other targets it got that name, but there is no real connection.

XiJinping

  • New member
  • *
  • Posts: 9
Re: Interfaces without CORBA, COM
« Reply #4 on: September 14, 2019, 08:32:34 am »
Thanks a lot.

BlackDoomer

  • New member
  • *
  • Posts: 9
  • Dmitry D. Chernov
    • Doom 2D - One of the best 2D platformers with amazing netgame!
Re: Interfaces without CORBA, COM
« Reply #5 on: November 14, 2024, 11:58:29 am »
"CORBA" interfaces on the other hand are raw interfaces. They don't inherit from anything and they don't provide reference counting, so you yourself are responsible that the class instance implementing the interfaces is freed at the end.
Why then the Free Pascal ReadMe makes a clear distinction between CORBA and raw interfaces?
For example: https://sourceforge.net/projects/freepascal/files/Win32/3.2.2/
Code: [Select]
****************************************************************************
* Features
****************************************************************************

<...>
- language features:
<...>
  - COM, CORBA and raw interfaces support

Thaddy

  • Hero Member
  • *****
  • Posts: 16199
  • Censorship about opinions does not belong here.
Re: Interfaces without CORBA, COM
« Reply #6 on: November 14, 2024, 12:30:38 pm »
CORBA interfaces ARE raw interfaces. They are also useless.
(well, they can be useful, but almost nobody knows how to use them properly and subsequently *lots* of wrong information is about.)
« Last Edit: November 14, 2024, 12:41:49 pm by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5763
  • Compiler Developer
Re: Interfaces without CORBA, COM
« Reply #7 on: November 14, 2024, 09:13:32 pm »
"CORBA" interfaces on the other hand are raw interfaces. They don't inherit from anything and they don't provide reference counting, so you yourself are responsible that the class instance implementing the interfaces is freed at the end.
Why then the Free Pascal ReadMe makes a clear distinction between CORBA and raw interfaces?
For example: https://sourceforge.net/projects/freepascal/files/Win32/3.2.2/

Because nobody is perfect and nobody reported that issue yet...

 

TinyPortal © 2005-2018