comp.lang.ada
 help / color / mirror / Atom feed
From: Alan Jump <alan.jump@gmail.com>
Subject: Re: GNAT GPL is proving...educational
Date: Sun, 21 Jul 2013 20:50:36 -0700 (PDT)
Date: 2013-07-21T20:50:36-07:00	[thread overview]
Message-ID: <be5b1878-f8f0-4448-adeb-9613f4c61b97@googlegroups.com> (raw)
In-Reply-To: <ksi8d0$5qn$1@dont-email.me>

On Sunday, July 21, 2013 8:26:10 PM UTC-7, Jeffrey Carter wrote:
 
> > package Stacks.Vector is
 
> >
 
> > one must use
 
> > package Stacks_Vector is
 
> > and then save the file as Stacks_Vector.ads.

> Stacks.Vector is a child package; its parent is package Stacks. Package Stacks 
> must exist to have child packages.

Tried it. Didn't work. GNAT responded "stacks.vector.ads language unknown". (Or something like that. I didn't write down the exact error message; I changed the filename and refactored the references from Stacks.Vector to Stacks_Vector and the problem went away. And yes, the Stacks interface package already existed.)

> GNAT's default naming rules expect the specification of package Stacks_Vector to 
> be in a file named stacks_vector.ads (all lower case) with its body in 
> stacks_vector.adb. (Package Stacks.Vector would be in a files named 
> stacks-vector.ad[sb].) Ada has nothing to say about source file names. Many 
> compilers will accept any file names you care to use.
 

I don't mind this at all. Especially with the option to generate body stubs from spec files. It works to make sure the body I write meets the spec I write. I wish Java had been that strict when I was learning that language; it would have saved me many hours of debugging, not to mention avoiding more than a few platefuls of spaghetti code. All I'm pointing out here is that it's forcing a shift in thinking about how I draft both specs and bodies, and that's a Very Good Thing(tm). 

 
> GNAT also requires one compilation unit per source file, but this again is not 
> something defined by the language, and many compilers will accept files 
> containing multiple compilation units. Many experienced Ada software engineers 
> find having a single compilation unit per file a good idea.

Here's another neophyte question, then...are specs and bodies considered separate compilation units? GNAT also complained when I tried to write a specification and body for a package in a single file. This may also have been me still learning GPS' options, and if they do have to be in separate files to keep GNAT happy without diving too deeply into options I don't need to be futzing with as a learner, so much the better. And like I pointed out, keeping them in separate files and generating a body stub from the specification does a lot in keeping me honest.

- -
73 de N5ILN
Alan

  reply	other threads:[~2013-07-22  3:50 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 [this message]
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
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