comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: GNAT GPL is proving...educational
Date: Mon, 22 Jul 2013 10:18:21 +0300
Date: 2013-07-22T10:18:21+03:00	[thread overview]
Message-ID: <b544luFcgc4U1@mid.individual.net> (raw)
In-Reply-To: <c87917bb-ecd1-4c2d-a5e9-3290ab2ca958@googlegroups.com>

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
      .      @       .

  parent reply	other threads:[~2013-07-22  7:18 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-22  1:28 GNAT GPL is proving...educational Alan Jump
2013-07-22  3:26 ` Jeffrey Carter
2013-07-22  3:50   ` Alan Jump
2013-07-22  5:11     ` Jeffrey Carter
2013-07-22 22:19       ` Shark8
2013-07-22  5:28     ` Bill Findlay
2013-07-22  8:49       ` Georg Bauhaus
2013-07-22  9:04         ` Bill Findlay
2013-08-01 15:07     ` Stephen Leake
2013-08-01 19:28       ` Alan Jump
2013-07-25  5:41   ` Yannick Duchêne (Hibou57)
2013-07-25 20:25     ` J-P. Rosen
2013-07-25 23:07       ` Yannick Duchêne (Hibou57)
2013-07-22  7:18 ` Niklas Holsti [this message]
2013-07-22  8:52   ` Simon Wright
2013-07-31  2:02   ` David Thompson
2013-07-22 18:28 ` Yannick Duchêne (Hibou57)
2013-07-22 19:04   ` Alan Jump
2013-07-22 19:49     ` Ludovic Brenta
2013-07-22 19:51     ` Simon Wright
2013-07-22 20:12     ` Jeffrey Carter
2013-07-22 23:34     ` Adam Beneschan
2013-07-23  3:46       ` Shark8
2013-07-23 17:46         ` Yannick Duchêne (Hibou57)
2013-07-27  3:17       ` Randy Brukardt
2013-07-29 17:21         ` Alan Jump
2013-07-29 20:57           ` Shark8
2013-07-29 21:30             ` Adam Beneschan
2013-07-29 21:44               ` Alan Jump
2013-07-29 22:36                 ` Yannick Duchêne (Hibou57)
replies disabled

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