[…]
Yes, because the @-operator simply returns a pointer. For example the following will compile without error as well:
[…]
This will only fail if {$T+} or {$TypedAddress On} is set which is not the case by default.
That’s inconsistent then. OkobaPatino’s program should compile without errors then, too. Nevertheless, FPC does not accept the address of the
TestString procedure to be assigned to a procedural variable that only accepts
TTestInt1 procedures. FPC’s error message is pretty specific about that:
project1.pas(30,8) Error: Incompatible types: got "<address of procedure(PString);Register>" expected "<procedure variable type of procedure(PInt1);Register>"
I guess the
@ we are using here is not the “real” address operator you can control by
{$typedAddress on}. After all, the
{$modeSwitch classicProcVars+} does allow you to omit it, so the fact that we are writing
@ before routine names is
just some
random syntax requirement, but the compiler can theoretically do without it, you don’t need to write an operator.
I think the actual issue is that there is no operator definition
operator := (p: PInt2): PString;