comp.lang.ada
 help / color / mirror / Atom feed
From: "G.B." <bauhaus@futureapps.invalid>
Subject: Re: Is there a way to do large block of source code comments
Date: Tue, 02 Sep 2014 15:14:48 +0200
Date: 2014-09-02T15:14:48+02:00	[thread overview]
Message-ID: <lu4fs5$q6q$1@dont-email.me> (raw)
In-Reply-To: <c6k4n1F944hU1@mid.individual.net>

On 01.09.14 22:53, Niklas Holsti wrote:
>> Ada 2012 aspect notation could add a tool-ready aspect that describes
>> >an entity in brief:
>> >
>> >   procedure Read (..., Item : out T)
>> >      with Comment => "... short description ...",
> That could be useful for ASIS tools (although I believe that ASIS
> already has some way to access the comments for a declaration), but I
> would object to using the word "Comment" as the aspect name, for the
> reasons I have given.

This aspect seems so easy to implement, yet so simple, useful,
and widespread (across languages) as to have a chance of being
acceptable as an addition to Ada. (GNAT, in particular, already
has Annotate, which is a lot more elaborate.)

Should I send this:

!topic An aspect for associating brief descriptions with declarations
!reference Ada 2012 RM 3, 6.1.1, K
!from Georg Bauhaus 14-09-02
!keywords aspects comments ASIS
!discussion

Starting with the Ada 83 style guide, there is advise on
commenting, a controversial yet much needed part of all
programs. The Ada language dispenses with any controversy by
simply providing the rules of “--” at the level of syntax. Tools
associating comments and declarations usually require some ad-hoc
convention that is not universal, which hinders integration. This
partly contrasts with Section 3.3 of the guidelines which state

  "o    Structure comments in headers so that information can be
        automatically extracted by a tool."


On the other hand, in Ada 2012, there now is a way for programmers
to "explain aspects of the code that are otherwise not
readily apparent." [ibid.]. This can be achieved, in part, by using
the contract related aspects of RM 6.1.1. Similarly, a standard
aspect for things still not readily apparent could be hooked to
an aspect, as explained below.

The focus of this aspect would be on indexes as found in books,
slightly adapted to the needs of programmers. For example, in
larger programming situations, it will be beneficial to have an
index of an Ada library that lists the entities declared therein
together with a short description, readable without reference to a
number of ad-hoc conventions for associating comments and
declarations. That is, for index style commenting to be useful
across projects, compilers, and tools, the name of a corresponding
aspect needs to be standardized.

It's value would be a string.

The idea is to have a very simple mechanism, easy to implement and
usable with tools simpler than ASIS (but not excluding the latter).
It is a compromise between today's implied, ad-hoc rules of comment
placement and a more express solution. The Java language is offering
@-keywords for this purpose; they are more elaborate, yet less
flexible.

An additional benefit of closer integration of "indexing comments"
with the language is that failing to update comments might be less
likely, because an aspect appears more pressing on change than
just about anything that can be put behind “--”, somewhere.

package Example
   with Indexing=> "declarations illustrating this submission"
is
    -- Not all comments are about one thing in particular.
    -- Not all comments are very brief.
    -- Some comments seem to have no reference at all.

    Buckets : Natural := 12
      with Indexing => "number of buckets configured",
        Atomic;

    function Drops (Bucket : Natural) return Natural
      with Indexing => "number of drops collected in Bucket",
        Post => (if Drops'Result = 0
                 then (not Is_Placed (Bucket) or No_Rain));
    -- TODO: replace Natural with a subtype for bucket numbering

end Example;



  reply	other threads:[~2014-09-02 13:14 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-01 17:24 Is there a way to do large block of source code comments gdotone
2014-09-01 19:04 ` Jeffrey Carter
2014-09-03  0:07   ` robin.vowels
2014-09-03  0:44     ` Jeffrey Carter
2014-09-03  1:15       ` gdotone
2014-09-03  4:17         ` J-P. Rosen
2014-09-03  8:04       ` Brian Drummond
2014-09-03  0:50     ` Adam Beneschan
2014-09-04  2:30       ` robin.vowels
2014-09-04 15:12         ` Adam Beneschan
2014-09-03  8:22     ` Georg Bauhaus
2014-09-03  8:28     ` Stefan.Lucks
2014-09-03  8:23       ` gdotone
2014-09-03  8:57         ` Pascal Obry
2014-09-03 15:12           ` Stefan.Lucks
2014-09-03 15:52             ` Pascal Obry
2014-09-03 17:48               ` Georg Bauhaus
2014-09-03 18:28                 ` Peter Chapin
2014-09-03 18:52               ` Adam Beneschan
2014-09-03 21:47                 ` gautier_niouzes
     [not found]                   ` <91e173a8-7451-4609-b141-ce3c6b19455f@googlegroups.com>
2014-09-04  5:56                     ` Pascal Obry
2014-09-03 22:42                 ` Georg Bauhaus
2014-09-03 21:02               ` Stefan.Lucks
2014-10-01 21:15                 ` Randy Brukardt
2014-09-03 16:58       ` Jeffrey Carter
2014-09-04 18:19       ` Keith Thompson
2014-09-03 15:32     ` Shark8
2014-09-04  2:37       ` robin.vowels
2014-09-04  7:20         ` Georg Bauhaus
2014-09-04 12:46           ` robin.vowels
2014-09-04 15:44             ` G.B.
2014-09-12  2:52         ` Shark8
2014-09-01 19:08 ` Niklas Holsti
2014-09-01 20:34   ` G.B.
2014-09-01 20:53     ` Niklas Holsti
2014-09-02 13:14       ` G.B. [this message]
2014-09-02 14:38         ` kalvin.news
2014-09-02 23:33         ` Randy Brukardt
2014-09-03  8:17           ` Georg Bauhaus
2014-09-01 21:15   ` Simon Wright
2014-09-02 15:01   ` Adam Beneschan
2014-09-02 16:35     ` Simon Wright
2014-09-02 17:14     ` Jeffrey Carter
2014-09-02 19:02     ` Niklas Holsti
2014-09-02 20:10       ` mockturtle
2014-09-02 23:36     ` Randy Brukardt
2014-09-01 19:13 ` Anh Vo
2014-09-01 21:04 ` gdotone
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox