[fpc-pascal] Assigning a result of a method reference
Michael Van Canneyt
michael at freepascal.org
Sat Jun 23 23:34:05 CEST 2007
On Sat, 23 Jun 2007, Joao Morais wrote:
>
> Hello,
>
> Taking the following code:
>
> {$mode objfpc}{$h+}
> class function tfoo.classmetadata: string;
> var
> vmetadatamethod: function: string of object;
> begin
> vmetadatamethod := @internalmetadatastr;
> // more code
> Result := vmetadatamethod;
> end;
>
> the last assignment doesn't compile, the compiler complains that:
>
> Error: Incompatible types: got "<procedure variable type of
> function:AnsiString of object;Register>" expected "AnsiString"
Try
Result := vmetadatamethod();
Strange code you have, Your code does not even compile under Delphi...
Michael.
More information about the fpc-pascal
mailing list