[Lazarus] Weird object variables access [SOLVED] - Delphi mode bug!
giuliano.colla at fastwebnet.it
Wed Oct 25 14:12:30 CEST 2017
Il 25/10/2017 13:41, Mattias Gaertner via Lazarus ha scritto:
> No. The Delphi syntax is "ProcIdentifier:=Proc" or
> The "@Some:=" means assign something to address of Some. Which is bogus.
> I guess Delphi's auto dereference actually translates this to
> @Some^:=. Still bogus, but valid bogus.
From embarcadero doc wiki
> Procedural Types in Statements and Expressions
> When a procedural variable is on the left side of an assignment
> statement, the compiler expects a procedural value on the right. The
> assignment makes the variable on the left a pointer to the function or
> procedure indicated on the right. In other contexts, however, using a
> procedural variable results in a call to the referenced procedure or
> function. You can even use a procedural variable to pass parameters:
> The *@* operator can also be used to assign an untyped pointer value
> to a procedural variable. For example:
> var StrComp: function(Str1, Str2: PChar): Integer;
> @StrComp:= GetProcAddress(KernelHandle, 'lstrcmpi');
This is no more true (as least as of X10 where I tested and it gave
rise to a compiler error), but it has been for a long time. That's why I
assumed that assigning an untyped pointer to a procedural variable was
both legal and also properly supported.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Lazarus