Forum > General

is and as operators with CORBA interfaces.

(1/6) > >>

soerensen3:
If I use "is" and "as" operators with CORBA interfaces I get:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Error: Class or COM interface type expected, but got "IP3DStreamableContainer"Explanation: Some operators, such as the AS operator, are only applicable to classes or COM interfaces.Does it mean it does not work with corba? I'm asking because here it is stated differently:

--- Quote ---The as and is operators also work on interfaces (both COM and CORBA). They can be used to check whether an interface also implements another interface as in the following example... https://www.freepascal.org/docs-html/ref/refsu51.html#x154-17600012.8.7
--- End quote ---

I'm wondering if the error is somewhere else (maybe because of an implicit IUnknown descendance) so it would be good to know if the message or the documentation is at fault.

taazz:
Is and As operators require that the interface has a GUID defined. In case of com this is the known GUID in case of CORBA this is a unique string (I think). With out them there is no way for the compiler to know.

Thaddy:
If you want to use CORBA with is and as you need an IDL typelibrary even when used locally. CORBA is usually a technically bad choice for local interfaces. Can you explain why you want to use CORBA? Or did you read the only shitty opinionated and ill-informed chapter in "Modern ObjectPascal" by M.Kamburelis? (Very good! except he does not understand interfaces and is stubborn about it, so skip that chapter (9)).

So: plz explain?

Note the manual does not include that and so is partially incorrect (CORBA needs IDL locally). Later on the manual even contradicts itself and explains it NEEDS to be COM, as the compiler says.
See last line of https://www.freepascal.org/docs-html/ref/refsu51.html#x154-17600012.8.7 which says:
"Although the interfaces must be COM interfaces, "

I'll see what I can do. There is a small example on how to use CORBA correctly on the wiki http://wiki.freepascal.org/Interfaces
That shows it is more cumbersome to use than COM.

mse:

--- Quote from: Thaddy on December 27, 2017, 08:50:48 am ---CORBA is usually a technically bad choice for local interfaces.
--- End quote ---
@soerensen3, please don't believe this statement, Thaddy is not right.
There also is no need for a "IDL-typelibrary', simply add a UID-string to the interface definition as taazz writes. MSEide has LeftClick-'Insert UID' in source editor in order to generate a UID-string based on a interface number. "is" and "as" can then be used with objectinstance and CORBA interface.

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---{$interfaces corba} itest = interface         ['AA']{0} end; itest1 = interface(itest) ['gA']{1}  procedure test(); end;[...] if theobjectinstance is itest1 then begin end; MSEgui also has "getcorbainterface()" in order to fetch a CORBA interface pointer from an objectinstance. Maybe there is a FPC-internal function now which can do the same, I don't remember.

Thaddy:

--- Quote from: mse on December 27, 2017, 11:32:16 am ---
--- Quote from: Thaddy on December 27, 2017, 08:50:48 am ---CORBA is usually a technically bad choice for local interfaces.
--- End quote ---
@soerensen3, please don't believe this statement, Thaddy is not right.

--- End quote ---
Well, then: give some compilable code. I am the first to admit it if I am wrong, and it still would be only partially:how do you explain the documentation? At best it is by accident. (And I still think local CORBA is unusable compared to COM interfaces when used locally, unless you are from outer space.) Point is: it does not matter if it works, but how it works and why it works. Noon use CORBA on a single machine: makes no sense. You do not have to use an (CORBA) interface if it is localanyway. Then you do not understand the concepts of CORBA and COM. COM has local merit because of memory management. CORBA hasn't....

Navigation

[0] Message Index

[#] Next page

Go to full version