On Fri, Mar 13, 2015 at 10:21 AM, Graeme Geldenhuys <
[email protected]> wrote:

> Sorry, but that is a false statement. It works for both COM and CORBA
> interfaces. Simply don't use the 'as' syntax - just cast it.
>

Wait, how can a syntax "work", if not used? :)

Don't forget that Pascal is safe-type language.
So "as" has also intent of checking an interface for being castable to an
object instance.

If an interface is originating from non-FPC environment (i.e. delphi, c++
or whatever langauge)  such casting should fail.
This is not the case for OP, but should be used as good practices.

Please note that casting Interface to TObject via "as" was not originally
in the compiler. It was eventually added for Delphi compatibility.
Previously compiler would just fail with an error that interface is not
castable to object at all (I.e. Delphi 7 won't allow the syntax as well)

http://www.freepascal.org/docs-html/ref/refsu47.html#x141-15100012.8.7

thanks,
Dmitry

P.S. By the way, if different versions of FPC are used (i.e. an interface
is loaded from a DLL) and then interface is typecasted to an object via
"as". It might cause problems if TObject structures are different between
host application and the library. But using interfaces only prevents the
problem.
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to