comp.lang.ada
 help / color / mirror / Atom feed
From: John Perry <john.perry@usm.edu>
Subject: Re: Why .ads as well as .adb?
Date: Mon, 3 Jun 2019 12:23:46 -0700 (PDT)
Date: 2019-06-03T12:23:46-07:00	[thread overview]
Message-ID: <2276685b-0e6b-46d1-ae7e-e7f1c0781dc0@googlegroups.com> (raw)
In-Reply-To: <glkqcpFsglcU1@mid.individual.net>

On Monday, June 3, 2019 at 9:50:03 AM UTC-5, Niklas Holsti wrote:
> > "teams can work separated from each other as needed, without the
> > project having to distribute all of the implementation to everyone"
> >
> > [Having separate specification files against which one can *compile*
> > would be useful, not just convenient, though I think it's arguable
> > that one can do this in Oberon, too, via .smb files and
> > documentation.]
> 
> If an Ada project needs to use an Ada library that is not open-source 
> and was developed by someone else, the library provider can deliver the 
> .ads source files to define the library API, but deliver only the object 
> code for the .adb files, thus keeping the library implementation secret. 
> Can Oberon .smb files do that?

Yes; that's the entire point of an .smb file. The Oberon compilers I'm familiar with generate both symbol (.smb) and object files (.o or .class, depending on the target). I've tested that they will check a module against .smb, without having an object file.

In Native Oberon, unexpected record fields are kept secret [1]. Wirth states in "Modula-2 and Oberon" [2] that symbol files have an advantage over source files, in that the compiler can record a version number with the file, and automatically update it.

> In Ada this can be done even if the library is actually implemented in 
> some other language such as C.

An Oberon compiler that targets native code allows one to create modules that define interfaces to C files [3]. Another, which targets the JVM, allows one to create modules that define interfaces to Java class files. [4]

> When I write client code for a package, I find it much more convenient 
> to study the package's interface from its .ads file, because the .ads 
> file is usually shorter than the .adb file and contains only information 
> useful to the client (up to the "private" part). However, I admit that a 
> smart IDE could display a filtered view of a "combined .ads/.adb" file, 
> showing me only the interface and not the implementation.

Right, this latter is what I'm referring to in general.

> That is true, IMO, for current Ada, but I'm sure that Ada could be 
> extended with pragmas or keywords to allow a combined .ads/.adb file 
> from which a "pure .ads" could be extracted. But I don't see any 
> advantage in that, given the other advantages of separate .ads and .adb.

That's fine; as I said, I'm curious. I've noticed that Ada's designers aren't reticent to adopt what they think are good ideas from other languages (e.g., Eiffel's contracts) so that made me wonder why the .ads/.adb distinction was retained, at least in gnat. (I'm not actually aware if that's required by the language itself.)

> No, gnatchop reads a source file that is a simple concatenation of any 
> number of .ads and .adb files, and just finds the boundaries of the 
> concatenated files and spits out the separated (de-concatenated) files. 
> It is a bit like "unzip" but uses Ada syntax to separate out the 
> individual files from the "archive" (the concatenated file).
> 
> Ada compilers other than GNAT accepted such concatenated input source 
> files as "compilations". Gnatchop was implemented to help apply GNAT to 
> such source files.

I completely misunderstood that. Thank you.

BTW, in case it hasn't been clear: there are plenty of ways I think Ada is far superior to Oberon. This is just one aspect of Oberon that originally I didn't like (when I was a Modula-2 programmer), and came to appreciate greatly only later.

john perry

[1] inf.ethz.ch/personal/wirth/Articles/Modula-Oberon-June.doc

[2] www.ethoberon.ethz.ch/native/compiler/obj081200/ObjectFile.html

[3] miasap.se/obnc/man/obnc.txt; see "Interfacing to C".

[4] github.com/lboasso/oberonc

  reply	other threads:[~2019-06-03 19:23 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
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 [this message]
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