comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Why .ads as well as .adb?
Date: Wed, 5 Jun 2019 17:41:54 -0500
Date: 2019-06-05T17:41:54-05:00	[thread overview]
Message-ID: <qd9gfj$6aj$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: f611bdb8-5a40-48bd-afe5-17de72bbe193@googlegroups.com

Maciej Sobczak" <see.my.homepage@gmail.com> wrote in message 
news:f611bdb8-5a40-48bd-afe5-17de72bbe193@googlegroups.com...
>> On the other hand, I like it that I can get a first impression of an Ada
>> program by reading just the .ads files.

...
>Say, I need this idiom in 10% of packages. Why am I
>penalized in the remaining 90% and forced to write specs
>that are demonstrably not needed?

I think you have this percentage backwards. You need this idiom in a 
significant majority of packages, certainly in anything object-based. I 
would have given the percentages as more like 80% need it and 20% don't.

After all, anything that doesn't benefit from separate specs really 
shouldn't be in a package in the first place. It might be in a package since 
some other package got unmanageably large (Janus/Ada has a lot of these, 
especially because of the size limits when it originally was created), but 
my experience is that such things are impediments to understanding the 
program and in finding where things really are. So it is best to avoid them.

...
>> Apart from all the other reasons already given, keeping spec and body in
>> the same file can cause compilation-order problems.
>
>Only if you assume that the compiler reads the file only once and therefore
>must validate everything in a single pass.

There's two parts to this. The first part is true of almost every compiler 
(GNAT is a weird exception). That's in large part because compiler 
performance is mostly bound by I/O time (memory management overhead taking 
much of the rest); outside of optimization, compilation simply doesn't do 
enough to show up in a CPU monitor (and this has been true for decades, at 
least since the early 1990s). The less I/O a compiler does, the faster it's 
build times are going to be. (Which probably doesn't matter for one file, 
but it certainly matters for systems with hundreds of units.)

The other part is true, but seems irrelevant. The issue being the increased 
coupling of putting all of the source in one file (which I do do from 
time-to-time). Before one can compile a source file, all of it dependencies 
have to exist and be compilable as well. Which means that when the body and 
spec are together, you have to have much more of the program compilable 
before any part of it (and the files that depend on it as well) can be 
compiled. But compiling is the best way to stamp out mistakes, and it has 
been proven that the earlier that you can catch a bug, the cheaper it is to 
fix. Delaying compilation just makes it more likely that you've forgotten 
part of your intent before the problem shows up.

>Which is not the case anyway, not even in Ada (nor in C++). That's why this
>concept looks a bit archaic today.

The concept of decreasing coupling seems just as relevant today as it was 
when it was designed into Ada 83. After all, a well-designed unit will only 
reference a handful of things in the specification and many things in the 
body. Mixing them increases the coupling for the compiler and for the 
reader.

                                        Randy.


                             Randy. 


  parent reply	other threads:[~2019-06-05 22:41 UTC|newest]

Thread overview: 88+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-02  0:48 Why .ads as well as .adb? John Perry
2019-06-02  5:42 ` J-P. Rosen
2019-06-02  6:39 ` Dmitry A. Kazakov
2019-06-03  7:35   ` Maciej Sobczak
2019-06-03  7:57     ` J-P. Rosen
2019-06-03 19:49       ` Keith Thompson
2019-06-04  8:03       ` Maciej Sobczak
2019-06-03  8:13     ` Dmitry A. Kazakov
2019-06-03 19:51       ` Keith Thompson
2019-06-03 20:18         ` Dmitry A. Kazakov
2019-06-04  8:24       ` Maciej Sobczak
2019-06-04  9:33         ` Dmitry A. Kazakov
2019-06-05  9:04           ` Maciej Sobczak
2019-06-05 12:48             ` Dmitry A. Kazakov
2019-06-05 17:12               ` G. B.
2019-06-05 18:50                 ` Optikos
2019-06-05 22:57                   ` Randy Brukardt
2019-06-04 22:28         ` Randy Brukardt
2019-06-05  8:28           ` Maciej Sobczak
2019-06-05  9:20             ` J-P. Rosen
2019-06-05  9:28               ` Paul Rubin
2019-06-05 10:11                 ` Niklas Holsti
2019-06-05 12:58                   ` Maciej Sobczak
2019-06-05 14:28                     ` Niklas Holsti
2019-06-06  7:34                       ` Maciej Sobczak
2019-06-06 19:51                         ` Keith Thompson
2019-06-06 20:27                           ` J-P. Rosen
2019-06-06 21:12                         ` Randy Brukardt
2019-06-06 21:17                         ` Randy Brukardt
2019-06-06 22:08                           ` Dennis Lee Bieber
2019-06-07  7:59                           ` Maciej Sobczak
2019-06-07 10:42                             ` alby.gamper
2019-06-07 16:59                               ` Dennis Lee Bieber
2019-06-07 14:10                             ` Brad Moore
2019-06-07 23:37                               ` Paul Rubin
2019-06-08  1:16                                 ` Brad Moore
2019-06-08  7:34                                   ` Simon Wright
2019-06-08 17:44                                 ` G.B.
2019-06-08 21:41                                 ` Keith Thompson
2019-06-09  0:40                                   ` Paul Rubin
2019-06-09 18:56                                     ` Keith Thompson
2019-06-09 20:35                                       ` John Perry
2019-06-09 21:15                                         ` Niklas Holsti
2019-06-09 22:37                                           ` John Perry
2019-06-10  9:01                                             ` Simon Wright
2019-06-10 13:15                                               ` Simon Wright
2019-06-10  9:22                                             ` Niklas Holsti
2019-06-09 21:37                                         ` Simon Wright
2019-06-09 22:40                                           ` John Perry
2019-06-10  9:07                                             ` Simon Wright
2019-06-09 21:46                                         ` Niklas Holsti
2019-06-10 17:11                                         ` Dennis Lee Bieber
2019-06-08  4:57                             ` Randy Brukardt
2019-06-08 23:57                               ` Optikos
2019-06-09  0:43                                 ` Paul Rubin
2019-06-10  8:17                               ` Maciej Sobczak
2019-06-10 19:10                                 ` G.B.
2019-06-10 22:07                                 ` Randy Brukardt
2019-06-11  0:32                                   ` Optikos
2019-06-11 15:39                                     ` Brad Moore
2019-06-11 16:14                                       ` John Perry
2019-06-11 16:46                                         ` Shark8
2019-06-11 19:29                                           ` John Perry
2019-06-14  6:12                                             ` Brad Moore
2019-06-14 21:51                                               ` John Perry
2019-06-14 16:29                                             ` djakoogler
2019-06-11 18:19                                         ` joakimds
2019-06-11 15:49                                   ` Jeffrey R. Carter
2019-06-07  7:36                       ` Niklas Holsti
2019-06-05 22:41                     ` Randy Brukardt [this message]
2019-06-06  3:34             ` Keith Thompson
2019-06-06  7:29               ` Maciej Sobczak
2019-06-06 15:30                 ` John Perry
2019-06-06 15:41                 ` Brad Moore
2019-06-06 19:42                 ` Keith Thompson
2019-06-06 16:37               ` Dennis Lee Bieber
2019-06-02  9:59 ` joakimds
2019-06-02 20:14 ` G.B.
2019-06-03 13:37 ` John Perry
2019-06-03 14:50   ` Niklas Holsti
2019-06-03 19:23     ` John Perry
2019-06-03 21:04       ` Niklas Holsti
2019-06-03 18:51   ` Lucretia
2019-06-03 19:32     ` John Perry
2019-06-03 17:00 ` Jeffrey R. Carter
2019-06-03 18:59   ` Lucretia
2019-06-03 19:29   ` John Perry
2019-06-03 20:00     ` Jeffrey R. Carter
replies disabled

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