View Issue Details

IDProjectCategoryView StatusLast Update
0038071FPCDocumentationpublic2020-11-16 17:44
ReporterOkobaPatino Assigned ToMichael Van Canneyt  
PrioritynormalSeverityminorReproducibilityN/A
Status closedResolutionfixed 
Fixed in Version3.3.1 
Summary0038071: State that declaration global operators in Delphi mode is not possible
DescriptionIt is not clear from this document that it is impossible to declare a global operator for a type.
https://www.freepascal.org/docs-html/ref/refse102.html
It should be something like this that these operators are not recognized in Delphi mode:
https://www.freepascal.org/docs-html/ref/refse109.html

To be clear, this code is not possible in Delphi mode but possible in objfpc mode:
program Project1;
 
{$MODE Delphi}
 
 
type
  complex = record
    re: Real;
    im: Real;
  end;
 
  operator assign (r: Real) z: complex;
  begin
    z.re := r;
    z.im := 0.0;
  end;
 
var
  R: Real;
  C: complex;
 
begin
  C := R;
end.
Additional Informationhttps://forum.lazarus.freepascal.org/index.php/topic,52117.0.html
TagsNo tags attached.
Fixed in Revision1774.
FPCOldBugId
FPCTarget3.2.2
Attached Files

Relationships

has duplicate 0038072 closedMichael Van Canneyt Documentation for operator overloading does not mention that global operator overloading is not possible in Delphi mode 

Activities

Bart Broersma

2020-11-12 18:09

reporter   ~0126864

B.t.w.: It also does not mention that you cannot use syntax like "operator + (R,L: TSomeType): TSomeType", but you have to use symbolic types ("add" in this case). At least according to Ebarcadero: http://docwiki.embarcadero.com/RADStudio/Sydney/en/Operator_Overloading_(Delphi)

Kai Burghardt

2020-11-13 03:03

reporter   ~0126869

Bart, it _does_ say below the table 15.1 “Operator Names”, quote:

*Remark* When compiling in `Delphi` mode the names of the operators _must_ be used, not the symbols.

Bart Broersma

2020-11-13 13:44

reporter   ~0126875

Last edited: 2020-11-13 13:50

View 2 revisions

@Kai
The official docs are at ftp://ftp.freepascal.org/pub/fpc/docs-pdf/ref.pdf
This document does NOT have a table in section 15.1 and the phrase "the names of the operators" does not appear in the entire document.

[Edit]
@Kai: I see now that you refer to https://www.freepascal.org/docs-html/ref/refse102.html

Kai Burghardt

2020-11-13 14:05

reporter   ~0126876

Are they?

As far as I understand Michael, the “official” official documentation is the repository. Supplying a PDF version is just a complimentary service, so are the HTML pages. If the tools used for that (pdflatex, text2ht) do not generate appropriate documents, it is “not our department”. After all, the source code `ref.tex` _does_ contain the proper statements.

Bart Broersma

2020-11-13 15:41

reporter   ~0126878

> Are they?

Maybe, or maybe not.
I would expect the pdf to be the same as the html files, since https://freepascal.org/docs.html points to the pdf in question.
I used the pdf, because you can search the whole document for phrases.

But this becomes a bit off-topic for the mattaer at hand.

Michael Van Canneyt

2020-11-13 16:50

administrator   ~0126882

Reworked the documentation on operator overloading.
Essentially:
- Global operators are not at all supported in mode Delphi.
- Global operators only work with symbols (+/-=* etc).
- In record class operator definitions, objfpc mode requires symbols, delphi mode allows both symbols and names.

Michael Van Canneyt

2020-11-13 16:53

administrator   ~0126884

@Bart:
Unfortunately, the PDF documentation files on the FTP site had not been updated :-(
(you could have spotted this in the version number, they dated from 2017)
But I did this now. Good that this discussion arose, or I would never have noticed.

Thanks !

OkobaPatino

2020-11-14 07:47

reporter   ~0126908

Thanks @michael.
When does the live document (that I linked to) will be updated?

Michael Van Canneyt

2020-11-14 11:19

administrator   ~0126911

When 3.2.2 is released, this should hopefully still be this year.

OkobaPatino

2020-11-14 11:39

reporter   ~0126913

Where can I check the last version documentation before reporting such a bug in the future? As maybe this one was fixed already, and the live version that I reported was old.
I checked the commit list of this (https://github.com/graemeg/freepascal/commits/master) mirror, but I couldn't find the change.

Michael Van Canneyt

2020-11-14 11:49

administrator   ~0126915

In subversion:
svn co https://svn.freepascal.org/svn/fpcdocs

Or on the web:
https://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/?root=docs

OkobaPatino

2020-11-14 13:21

reporter   ~0126921

So there is no way to see them as the web document (with pages like the live version) to find the values quickly.
Something like https://dev.mysql.com/doc/refman/5.7/en/ to move between versions will be useful.
But I found your changes, and they are much more apparent. Thank you.

OkobaPatino

2020-11-16 17:44

reporter   ~0126985

Checked and it is now clear.
Thank you.

Issue History

Date Modified Username Field Change
2020-11-12 16:40 OkobaPatino New Issue
2020-11-12 16:40 OkobaPatino Status new => assigned
2020-11-12 16:40 OkobaPatino Assigned To => Michael Van Canneyt
2020-11-12 18:07 Michael Van Canneyt Relationship added has duplicate 0038072
2020-11-12 18:09 Bart Broersma Note Added: 0126864
2020-11-13 03:03 Kai Burghardt Note Added: 0126869
2020-11-13 13:44 Bart Broersma Note Added: 0126875
2020-11-13 13:50 Bart Broersma Note Edited: 0126875 View Revisions
2020-11-13 14:05 Kai Burghardt Note Added: 0126876
2020-11-13 15:41 Bart Broersma Note Added: 0126878
2020-11-13 16:50 Michael Van Canneyt Status assigned => resolved
2020-11-13 16:50 Michael Van Canneyt Resolution open => fixed
2020-11-13 16:50 Michael Van Canneyt Fixed in Version => 3.3.1
2020-11-13 16:50 Michael Van Canneyt Fixed in Revision => 1774.
2020-11-13 16:50 Michael Van Canneyt FPCTarget => 3.2.2
2020-11-13 16:50 Michael Van Canneyt Note Added: 0126882
2020-11-13 16:53 Michael Van Canneyt Note Added: 0126884
2020-11-14 07:47 OkobaPatino Note Added: 0126908
2020-11-14 11:19 Michael Van Canneyt Note Added: 0126911
2020-11-14 11:39 OkobaPatino Note Added: 0126913
2020-11-14 11:49 Michael Van Canneyt Note Added: 0126915
2020-11-14 13:21 OkobaPatino Note Added: 0126921
2020-11-16 17:44 OkobaPatino Status resolved => closed
2020-11-16 17:44 OkobaPatino Note Added: 0126985