comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: null declarative parts (was: Re: Elaboration order handling)
Date: Fri, 21 Jun 2013 14:58:49 -0400
Date: 2013-06-21T14:58:49-04:00	[thread overview]
Message-ID: <wccsj0buw7q.fsf_-_@shell01.TheWorld.com> (raw)
In-Reply-To: kq0ns4$oce$2@dont-email.me

Jeffrey Carter <spam.jrcarter.not@spam.not.acm.org> writes:

> On 06/20/2013 08:11 AM, Robert A Duff wrote:
>>
>> P.S. I don't like your convention of putting "-- null;" in empty
>> declarative parts!  Comments should impart useful information,
>> and empty declarative parts are nothing special, and anyway,
>> I can see it's empty without a comment.
>
> The I guess you'd prefer
>
> while Function_With_Side_Effects loop
> end loop;

A loop with no statements is something special and rare; the reader's
attention should be drawn to it.  So I don't mind putting "null;".
Empty declarative parts are not special, and are common.

I wouldn't mind if Ada didn't require "null;" in that loop, but
then I'd leave a blank line to make it stand out:

    while Function_With_Side_Effects loop

    end loop;

Or I'd put a comment:

    while Function_With_Side_Effects loop
        -- Nothing to do here.
    end loop;

Or maybe even a comment explaining why there's nothing to do.

I'm not 100% opposed to functions with side effects, but they should
be rare, and the above loop code is therefore dubious.  So it should
stand out.

Certain languages like C and Pascal have an error-prone syntax:

    while (...);
               ^ There's an empty loop body there, but you can't see it!

There are (at least) two ways to fix that:  (1) Require null statements
to be explicit.  (2) Require "end loop", "end if", and so on.
Ada does both, which is a belts and suspenders solution.
I think (2) is a great idea.  As for (1), I can take it or leave it --
shrug.

On a related subject, I would eliminate the "begin" in the middle of
a procedure body, and allow mixing of declarations and statements
without using block statements.  I would ALLOW block statements,
but their syntax would be something like:

    begin
        ... -- statements and declarations
    end;

Since declarations are executable in Ada, it makes no sense to have
a strong separation between the declarations and the statements
of a procedure body (and similar constructs).  That syntax is
a vestige that was inherited from Pascal for no good reason.

> to the Ada requirement that you have to put a null statement in there? I
> like the idea that something that's empty has to have something special
> in it to show that it's deliberately empty, and think it should apply to
> declarative parts, as well.

I don't expect to convince you.  It's largely a matter of taste.
I tried to explain the reasons for my "taste" above.

You probably like the syntax "(null record)" for an empty aggregate;
I would prefer "[]" (with square brackets).  I might leave a blank,
to emphasize its emptiness -- "[ ]" -- but that's as far as I'd go.

- Bob

  parent reply	other threads:[~2013-06-21 18:58 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-17 10:57 Range check for type 'Integer' Peter Brooks
2013-06-17 11:23 ` Simon Clubley
2013-06-17 11:54   ` Simon Wright
2013-06-17 12:55   ` Peter Brooks
2013-06-17 13:28     ` Shark8
2013-06-17 13:45       ` Peter Brooks
2013-06-17 21:16         ` Shark8
2013-06-18 10:48     ` Stephen Leake
2013-06-17 12:46 ` Dmitry A. Kazakov
2013-06-17 13:23 ` Bug in 'gnatmake' (Was: Range check for type 'Integer') Jacob Sparre Andersen
2013-06-17 13:32   ` Bug in 'gnatmake' Jacob Sparre Andersen
2013-06-17 16:50   ` Bug in 'gnatmake' (Was: Range check for type 'Integer') Robert A Duff
2013-06-17 19:15     ` Peter Brooks
2013-06-17 21:09       ` Shark8
2013-06-17 21:22       ` Jeffrey Carter
2013-06-18  1:21         ` Peter Brooks
2013-06-18  6:33           ` Jeffrey Carter
2013-06-18  7:29       ` Georg Bauhaus
2013-06-17 18:49   ` Bug in 'gnatmake' Simon Wright
2013-06-18  9:09     ` Elaboration order handling (Was: Bug in 'gnatmake') Jacob Sparre Andersen
2013-06-18 17:09       ` Robert A Duff
2013-06-18 22:52         ` Adam Beneschan
2013-06-19  1:21           ` Jeffrey Carter
2013-06-19 12:38             ` Robert A Duff
2013-06-19 20:43               ` Georg Bauhaus
2013-06-20  0:37                 ` Robert A Duff
2013-06-20 19:56                   ` Georg Bauhaus
2013-06-19 12:22           ` Robert A Duff
2013-06-19 15:46             ` Adam Beneschan
2013-06-19 16:41               ` Robert A Duff
2013-06-19 20:47               ` Georg Bauhaus
2013-06-19 21:36                 ` Adam Beneschan
2013-06-20  0:57                 ` Robert A Duff
2013-06-20  1:09                   ` Jeffrey Carter
2013-06-20  2:29                     ` Adam Beneschan
2013-06-20  6:08                       ` Jeffrey Carter
2013-06-20 15:11                     ` Robert A Duff
2013-06-21  5:26                       ` Jeffrey Carter
2013-06-21 15:48                         ` Adam Beneschan
2013-06-21 18:35                           ` Jeffrey Carter
2013-06-21 19:10                             ` Robert A Duff
2013-06-21 21:27                               ` Jeffrey Carter
2013-06-21 20:43                             ` Adam Beneschan
2013-06-21 21:44                               ` Jeffrey Carter
2013-06-21 23:47                                 ` Robert A Duff
2013-06-23 14:43                                   ` AdaMagica
2013-06-21 18:58                         ` Robert A Duff [this message]
2013-06-21 20:42                           ` null declarative parts Georg Bauhaus
2013-06-20  2:11                   ` Elaboration order handling (Was: Bug in 'gnatmake') Adam Beneschan
2013-06-20 14:44                     ` Robert A Duff
2013-06-20 11:24                   ` G.B.
2013-06-20 15:23                     ` Robert A Duff
2013-06-19 21:00             ` Georg Bauhaus
2013-06-19 22:26             ` Randy Brukardt
2013-06-20  0:31               ` Robert A Duff
2013-06-20 21:36                 ` Randy Brukardt
2013-06-19 13:07         ` Bill Findlay
replies disabled

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