From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: GNAT GPL is proving...educational Date: Mon, 22 Jul 2013 10:18:21 +0300 Organization: Tidorum Ltd Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: individual.net Iazllzx4yehivnlt4ujxqAMJiL+H66UJBonB1SGKhgvSDL7PB4 Cancel-Lock: sha1:0pvbusrsPrU9EpFneZfQroicW4U= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 In-Reply-To: Xref: news.eternal-september.org comp.lang.ada:16462 Date: 2013-07-22T10:18:21+03:00 List-Id: On 13-07-22 04:28 , Alan Jump wrote: > A neophyte commentary follows...pardon me whilst I > pull on my flame-retardant underwear. :-) Such special foundation garments are rarely needed in comp.lang.ada, I am glad to say. > Learning Ada has its pitfalls and pratfalls, just as learning > any other language. I've just run across a couple of them, > thanks to the example code provided with Barnes' "Programming > in Ada 2005". First off is an apparent change in coding style > required by GNAT... GNAT does not require changes in coding style, but the default GNAT naming convention for files replaces "." in the Ada name with "-" in the file name. The default names can be overridden by using a GNAT project file. > package Stacks.Vector is As others have said, the GNAT default file name for this packagte declaration is stacks-vector.ads For the Ada unit A.B.C, the default file name is a-b-c, followed by ".ads" for the declaration part and ".adb" for the body part. See http://gcc.gnu.org/onlinedocs/gnat_ugn_unw/File-Naming-Rules.html#File-Naming-Rules. If you are interested in the background for why GNAT has a default file naming convention, and insists on a single unit per file, see http://gcc.gnu.org/onlinedocs/gnat_ugn_unw/The-GNAT-Compilation-Model.html#The-GNAT-Compilation-Model. > The other unexpected (but, on reflection, totally logical) > curveball is that GNAT, and Ada in general, really doesn't like > monolithic program files... Not true for Ada in general, but true for GNAT and for most Ada programmers (and also C programmers, who almost without exception have separate .h and .c files). > I would have simply blamed GNAT, but the same problem occurred > when trying to load the example source code through AdaGIDE, so > it's clearly a shift in thinking now required by Ada. Not required by Ada, but by GNAT and perhaps by AdaGIDE (I don't know enough about the latter to say for sure). But Ada does emphasize the separation of specification (declaration) and implementation (body), making it natural to keep them in separate files. Note that AdaCore provides the "gnatchop" tool to split multi-unit source files into single-unit files following the GNAT default naming rules. Basically, you say gnatchop multi-unit-file-name and the resulting single-unit files appear in the working directory. > Package specifications get their own .ads file, everything else > goes in .adb files. Just so. > Coming from a background that involved FORTRAN and some basic-level > Java6, there's a definite learning curve. Understandable. Original Fortran had no formal separation of specification and implementation, and Java unfortunately puts both in the same file, as I understand it. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .