[fpc-pascal] Improved FPC JSON-RPC support
Mattias Gaertner
nc-gaertnma at netcologne.de
Wed Dec 29 00:21:35 CET 2021
On Tue, 28 Dec 2021 23:11:42 +0100 (CET)
Michael Van Canneyt via fpc-pascal <fpc-pascal at lists.freepascal.org>
wrote:
>[...]
> > Slightly off topic, and my Object Pascal is getting a bit rusty as
> > the years go by. <grin> ;-) In your factory above, is the "as
> > IInterface" part needed.
No.
> Can't the FPC compiler automatically cast
> > the return type based on the function return type, and the fact
> > that the compiler should know that TIntf2Impl type implements
> > TInterfacedObject?
Yes.
> No, theoretically it probably could, but type inference is not
> implemented in Pascal.
This is not type inference.
It compiles with fpc and pas2js:
Function GetMyOtherInterface(Const aName : string) : IInterface;
begin
Result:=TIntf2Impl.Create;
end;
Mattias
More information about the fpc-pascal
mailing list