[lazarus] circular unit reference
Florian Klaempfl
Florian.Klaempfl at gmx.de
Sat Nov 15 10:28:28 EST 2003
Andreas Hausladen wrote:
> ----- Original Message -----
> From: "Marc Weustink" <marc at dommelstein.net>
>
>>For those who wonder... this is why ifdefs make things unreadable
>>
>>- if FOnCompare=AValue then exit;
>>+ if {$IFDEF FPC}{$ELSE}@{$ENDIF}FOnCompare={$IFDEF
>>FPC}{$ELSE}@{$ENDIF}AValue then exit;
>
>
> I know this. But as Delphi needs an @ operator for a comparison fpc does not need one. Maybe I should write
> {$ifdef FPC}
> if FOnCompare = AValue then Exit;
> {$else}
> if @FOnCompare = @AValue then Exit;
> {$endif}
> Here FPC's syntax is in my eyes ambigious because if AValue is a function with no arguments it could be a function call.
No. FPC won't do a function call in any case when compiling this in
objfpc mode even if AValue returns a procedure variable. If you want to
call AValue do
if FOnCompare = AValue() then Exit;
This is very Cish but it makes procedure variable code much more
readable and less ambigious. However, I never tried if FPC handles
correctly a procedure variable call returning a procedure variable and
call this one, i.e.
if FOnCompare = AValue()() then Exit;
:)
>
> Some features of FPC are better than Delphi's but Delphi also has features FPC does not have. Another example is the event
> assignment where I found FPC syntax better than Delphi's.
> Obj.OnClick := {$ifdef FPC}@{$endif}MyEventHandler;
Compiling this with -Sd and you don't the @ ;) However I know this isn't
an option for the lcl.
More information about the Lazarus
mailing list