Recent

Author Topic: Fpc documentation completely ignores commonly used "{%H-}"  (Read 5627 times)

lagprogramming

  • Sr. Member
  • ****
  • Posts: 407
Fpc documentation completely ignores commonly used "{%H-}"
« on: April 28, 2023, 10:49:20 am »
Searching in the Fpc, MseIde/MseGui and Lazarus directories for "{%H-}" shows many occurrences. When I searched in the documentation of the latest stable FPC for "{%" I couldn't find anything. Might be a good idea to update the documentation so that the next stable release would also cover this subject.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11944
  • FPC developer.
Re: Fpc documentation completely ignores commonly used "{%H-}"
« Reply #1 on: April 28, 2023, 11:05:16 am »
FPC does nothing with {%H-}, Lazarus does. So it should be in the Lazarus documentation.
« Last Edit: April 28, 2023, 11:49:09 am by marcov »

AlexTP

  • Hero Member
  • *****
  • Posts: 2488
    • UVviewsoft
Re: Fpc documentation completely ignores commonly used "{%H-}"
« Reply #2 on: April 28, 2023, 11:45:15 am »
@macrov,
Report is about {%H}, not {$H}

Posted to bugtracker,
https://gitlab.com/freepascal.org/fpc/documentation/-/issues/39346

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11944
  • FPC developer.
Re: Fpc documentation completely ignores commonly used "{%H-}"
« Reply #3 on: April 28, 2023, 11:49:33 am »
Typo, I meant %H yes.  {% convention is Lazarus only.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10553
  • Debugger - SynEdit - and more
    • wiki
Re: Fpc documentation completely ignores commonly used "{%H-}"
« Reply #4 on: April 28, 2023, 12:09:15 pm »
Code: Pascal  [Select][+][-]
  1. {%H-}

Is documented in the FPC docs https://www.freepascal.org/docs-html/ref/refse2.html#x10-90001.2

"{" begins a comment.
The above code is a comment, indeed. Well, at least as far as fpc is concerned.

The Lazarus IDE handles all sorts of comments. E.g. comments in front/after a method declaration may be shown as hint by the IDE, if hovering an invocation of that method.

"{%" is also a comment handled by the IDE.
When the IDE reads the compiler output during compilation, and the IDE finds hints produced by the compiler then it may filter them from the output shown in the messages window.
The compiler has no idea, what the IDE will do with the output. And the compilers output is not changed by that comment.


The IDE also handles "{%region}", which to the compiler is also just a comment.
« Last Edit: April 28, 2023, 12:11:35 pm by Martin_fr »

dseligo

  • Hero Member
  • *****
  • Posts: 1412
Re: Fpc documentation completely ignores commonly used "{%H-}"
« Reply #5 on: April 28, 2023, 12:58:04 pm »
Code: Pascal  [Select][+][-]
  1. {%H-}

Is documented in the FPC docs https://www.freepascal.org/docs-html/ref/refse2.html#x10-90001.2

"{" begins a comment.
The above code is a comment, indeed. Well, at least as far as fpc is concerned.

With this logic, {$R} is also a comment, but FPC fails to compile this:
Code: Pascal  [Select][+][-]
  1. program test;
  2.  
  3. {$R}
  4.  
  5. begin
  6.  
  7. end.

Is documentation wrong?

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10553
  • Debugger - SynEdit - and more
    • wiki
Re: Fpc documentation completely ignores commonly used "{%H-}"
« Reply #6 on: April 28, 2023, 01:08:51 pm »
Code: Pascal  [Select][+][-]
  1. {%H-}
Is documented in the FPC docs https://www.freepascal.org/docs-html/ref/refse2.html#x10-90001.2

"{" begins a comment.

With this logic, {$R} is also a comment, but FPC fails to compile this:

Well, but "{$" is documented. (I am not searching the link now, but I do recall having seen it, even studied some of that part of the docs)
Albeit, not in the language ref itself, since it is not part of the Pascal language. Not even (as far as I understand) part of the particular dialect. Rather it is a compiler feature.

"{%" has no documentation, that gives it any additional meaning ("docs" and "meaning" within the scope concerning the language/compiler). Therefore it is a comment.

Code: Pascal  [Select][+][-]
  1. type x = class
  2. // About foo
  3. procedure foo;

"//" is a comment. Yet Lazarus uses it as hint, like documentation.


{%
only has meaning in the Lazarus IDE

dseligo

  • Hero Member
  • *****
  • Posts: 1412
Re: Fpc documentation completely ignores commonly used "{%H-}"
« Reply #7 on: April 28, 2023, 01:21:12 pm »
Code: Pascal  [Select][+][-]
  1. {%H-}
Is documented in the FPC docs https://www.freepascal.org/docs-html/ref/refse2.html#x10-90001.2

"{" begins a comment.

With this logic, {$R} is also a comment, but FPC fails to compile this:

Well, but "{$" is documented.

My point was: there is no mention of that in link you provided neither for '{%H' nor for '{$R'.

dseligo

  • Hero Member
  • *****
  • Posts: 1412
Re: Fpc documentation completely ignores commonly used "{%H-}"
« Reply #8 on: April 28, 2023, 01:21:27 pm »
Searching in the Fpc, MseIde/MseGui and Lazarus directories for "{%H-}" shows many occurrences. When I searched in the documentation of the latest stable FPC for "{%" I couldn't find anything. Might be a good idea to update the documentation so that the next stable release would also cover this subject.

https://wiki.freepascal.org/IDE_directives

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10553
  • Debugger - SynEdit - and more
    • wiki
Re: Fpc documentation completely ignores commonly used "{%H-}"
« Reply #9 on: April 28, 2023, 01:51:31 pm »
My point was: there is no mention of that in link you provided neither for '{%H' nor for '{$R'.

Well, there cannot be a mention of "{%". It does neither exist from the language side, nor from the compiler.

From the language point of view, both "{$" and "{%" are comments.
From the compiler view"{$" has a meaning and is documented.

It may be debatable if the language doc, should refer to special constructs that are a compiler feature. After all, while it may not be seen as part of the language (not sure if it is, or is not), the particular language ref/doc is specially for the implementation by this compiler.


As for the "{%" it is neither documented in the compiler, nor in the language. In the same way "{foobar}" is also not documented, other than by the documentation for comments.

A % in a comment is no different than a foobar. So why would there be any other documentation for this, than the one about comments?
And how does that relate to the question if "{$" should be somehow mentioned as special in the doc of comments?
- If yes "{$" should be mention => then "{%" would still be the same as {foobar}
- If no "{$" need no mention, as it can be found in compiler docs, then by conclusion if "{%" cannot be found in compiler docs, it is the same as {foobar}.


Any mention of "{%" in either compiler or language docs, would only be expectable, if features of the Lazarus IDE were to be documented in the FPC docs. But then it wouldn't be FPC docs?
What if, some other IDE starts using "(*--HideHint: 1234*)" should that then be in the FPC docs?

lagprogramming

  • Sr. Member
  • ****
  • Posts: 407
Re: Fpc documentation completely ignores commonly used "{%H-}"
« Reply #10 on: April 28, 2023, 02:19:00 pm »
So, pascal code compiled in the past using Lazarus has been modified in order to hide some messages. The code that has been modified specially for the Lazarus IDE, reached both FPC and MseGui/MseIde projects. This is the explanation for those "{%H-}" texts appearing in all three projects, not that FPC documentation would need modifications, right!?

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10553
  • Debugger - SynEdit - and more
    • wiki
Re: Fpc documentation completely ignores commonly used "{%H-}"
« Reply #11 on: April 28, 2023, 02:55:42 pm »
So, pascal code compiled in the past using Lazarus has been modified in order to hide some messages. The code that has been modified specially for the Lazarus IDE, reached both FPC and MseGui/MseIde projects. This is the explanation for those "{%H-}" texts appearing in all three projects,

Probably... I don't know if MSE... does itself anything with "{%".

Quote
not that FPC documentation would need modifications, right!?

You can compile any source with FPC outside any IDE. And you will then notice that the presence of "{%H-}" does not affect FPC in any way.
You can also put "{%foo}" into the sources. FPC wont mind.

From the point of FPC it is a comment. Nothing more.

From the point of (a) product(s) build on top of FPC => it has a meaning.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10553
  • Debugger - SynEdit - and more
    • wiki
Re: Fpc documentation completely ignores commonly used "{%H-}"
« Reply #12 on: April 28, 2023, 03:04:02 pm »
There are also several *.lpi and at least one *.lpk file in the fpc sources. Those are files for Lazarus. So, obviously fpc sources come with some content that is meant for Lazarus.

Чебурашка

  • Hero Member
  • *****
  • Posts: 586
  • СЛАВА УКРАЇНІ! / Slava Ukraïni!
Re: Fpc documentation completely ignores commonly used "{%H-}"
« Reply #13 on: May 02, 2023, 03:16:48 pm »
An extra question about {%H-}: i noticed that hints marked with this are hidden when compiling with Lazarus, but not when compilin with lazbuild... is this correct or am I wrong?

FPC 3.2.0/Lazarus 2.0.10+dfsg-4+b2 on Debian 11.5
FPC 3.2.2/Lazarus 2.2.0 on Windows 10 Pro 21H2

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10553
  • Debugger - SynEdit - and more
    • wiki
Re: Fpc documentation completely ignores commonly used "{%H-}"
« Reply #14 on: May 02, 2023, 04:03:37 pm »
An extra question about {%H-}: i noticed that hints marked with this are hidden when compiling with Lazarus, but not when compilin with lazbuild... is this correct or am I wrong?

I don't know....

It could be that the code is to IDE specific. And that too much code would need to be pulled into lazbuild.
I.e., I don't expect that Lazbuild is scanning sources (using codetools). But that is a pre-requisite for dealing with {%H-}.

Or it could be an oversight.


 

TinyPortal © 2005-2018