[Lazarus] Weird object variables access [SOLVED] - Delphi mode bug!

Giuliano Colla 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
> "ProcIdentifier:=@Proc".
>
> 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 
(http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Procedural_Types_(Delphi)):

>
>     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:
>
[snip]

> 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.

Giuliano


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20171025/78756cb9/attachment.html>


More information about the Lazarus mailing list