Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2013-11

Another bug or feature

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Juha Manninen

This is related to issue #24907.
In the comment I explain the problem :
http://bugs.freepascal.org/view.php?id=24907#c71475 but I copy it also here below.
Now, is it a bug or feature?
Otherwise not a big deal but CodeTools follow FPC behavior and the Delphi converter uses CodeTools. Apparently valid Delphi code cannot be converted because of this problem.

---

Neither codetools nor FPC 2.6.2 supports the "operator <" syntax in {$mode delphi}. It is ok in {$mode objfpc}.
Try to code complete and compile the code below. Then try again with {$mode objfpc}.
How does FPC trunk behave?
If the syntax is indeed supported by Delphi then this is a bug in FPC's mode delphi. Codetools only follows the syntax rules of FPC. Who will open a report for FPC?

-----------------------
unit Unit2;
{$mode delphi}
interface
type
  TRootMove = record
    score: integer;
    node_count: uint64;
  end;
  operator < (m1, m2: TRootMove) LessThan : Boolean;
implementation
operator < (m1, m2: TRootMove) LessThan : Boolean;
begin
  if m1.score  m2.score then
    result := m1.score < m2.score
  else
    result := m1.node_count < m2.node_count;
end;
end.

Reply by email

Sven Barth
to Juha Manninen
"Juha Manninen" wrote 23 lines
unit Unit2; {$mode delphi} interface type TRootMove = record score: integer; node_count: uint64; end; operator < (m1, m2: TRootMove) LessThan : Boolean; implementation operator < (m1, m2: TRootMove) LessThan : Boolean; begin if m1.score m2.score then result := m1.score < m2.score else result := m1.node_count < m2.node_count; end; end.

Neither global operators nor symbolic (<, >, etc.) operator names are supported by Delphi.

Regards,
Sven

Reply by email

Juha Manninen
to Sven Barth
Sven Barth wrote
Neither global operators nor symbolic (<, >, etc.) operator names are supported by Delphi.

You are right.
Now looking more carefully at the example critterchess code : http://sourceforge.net/projects/critterchess
it is already partly ported for FPC. There is no Lazarus project but the code has IFDEFs:

{$ifndef FPC}
class operator TRootMove.LessThan(m1, m2: TRootMove): boolean;
{$else}
operator < (m1, m2: TRootMove) LessThan : boolean;
{$endif}

The converter defines Mode Delphi and FPC is already defined. The result is illegal code.
This is a good example of a strange code variation the converter gets. It cannot tackle all of them.

Juha

Reply by email