AdaCore / ada-spark-rfcs

Platform to submit RFCs for the Ada & SPARK languages
63 stars 28 forks source link

Support of comment block #42

Closed pjljvandelaar closed 4 years ago

pjljvandelaar commented 4 years ago

We at ESI perform among others code analysis. We would like to present the code analysis results in a straight forward way. One such way is incorporating the analysis results in the original code, since the developers are familiar with that code. However, we prefer to minimally change the layout of the code (including line numbers) to keep that familiarity. In other language, we can use a comment block (e.g. / / in C). Ada lacks such a feature. The user has no control over the location where a comment ends - it always ends with a line break. Adding comment thus enforces a line break and thus change layout and line numbers. We are aware of the discussion on stack overflow. Yet the discussion on stackoverflow focusses only on multi line comments. We have a need for comments that are smaller than a single line.

Just to give an illustrative example: We prefer the analysis output

function Go (D /* 3,4,7 */, F /* 100, 1000 */ : Integer) return Integer;

over

function Go (D,          -- 3,4,7 
             F : Integer -- 100, 1000
            ) return Integer;

when the original code is

function Go (D, F : Integer) return Integer;

During a meeting with AdaCore, Nexperia and ESI, we were asked by AdaCore to submit this issue to trigger a discussion to determine whether a RFC is justified.

setton commented 4 years ago

Could you emit something like this?

   function Go (D, F : Integer) return Integer;  --  D:3,4,7  F: 100,1000

One advantage is that it preserves both lines and columns in the original code.

yannickmoy commented 4 years ago

Ada lacks block comments by design, to avoid pitfalls associated with the use of block comments. See for example https://learn.adacore.com/courses/SPARK_for_the_MISRA_C_Developer/chapters/03_syntactic_guarantees.html#distinguishing-code-and-comments

If the solution given by @setton is not suitable for you, you could either:

pjljvandelaar commented 4 years ago

Could you emit something like this? function Go (D, F : Integer) return Integer; -- D:3,4,7 F: 100,1000

One advantage is that it preserves both lines and columns in the original code.

This is definitely a workable solution. Thanks for the suggestion!