15

Why is there no multiple or block comment in Ada programming like the C/C++ /* */?

Simon Wright
  • 25,108
  • 2
  • 35
  • 62
leuage
  • 566
  • 3
  • 17
  • I don't think C++ programmers actually use this kind of comment much any more. Java programmers generally only use it for comments with a special format recognized by a documentation generator. – ajb Nov 22 '14 at 17:20

2 Answers2

18

The Ada 83 Rationale Section 2.1 says

No form of embedded comments (within a line of text) is provided, as their utility is insufficient to justify the extra complexity. Single comments that are larger than one line are not provided. Such comments would require a closing comment delimiter and this would again raise the dangers associated with the (unintentional) omission of the closing delimiter: entire sections of a program could be ignored by the compiler without the programmer realizing it, so that the program would not mean what he thinks. Long comments can be written as a succession of single line comments, thus combining elegance with safety.

Of course modern IDEs will colourise comments, but you might not notice, and the compiler certainly won’t.

Simon Wright
  • 25,108
  • 2
  • 35
  • 62
  • 3
    Modern IDEs will also put line-comment indicators (`--` in Ada, `//` in many other languages) on blocks of multiple lines for you, lessening the need for the `/*...*/`-like syntax. – ajb Nov 22 '14 at 17:17
  • 1
    Multiple comments block is more used for debugging and hiding sections of code then actual comments when coding prototypes. Users may not be aware of or not having a IDE with comment colonizing tool thus making a multiple comments block useful for that type of situations. – Jossi Dec 02 '14 at 20:18
-1

You could always use:

if(False) then

... ... Code goes here ...

end if;

  • 1
    Alsmot sure it will trigger a compiler warning for unreacheable code (warnings in most critical software development process are treated as error) – LoneWanderer Apr 17 '20 at 12:23
  • This only allows you to comment out valid chunks of code, in addition to the comment mentioning this giving a compiler warning – CoffeeTableEspresso Jan 11 '21 at 20:40