comp.lang.ada
 help / color / mirror / Atom feed
From: Jinsong Zhao <jszhao@yeah.net>
Subject: Re: how to organize source code for a complete software? Thanks!
Date: Mon, 10 Oct 2011 14:02:51 +0800
Date: 2011-10-10T14:02:51+08:00	[thread overview]
Message-ID: <j6u1qd$k6i$1@dont-email.me> (raw)
In-Reply-To: <op.v23hv5wlule2fv@index.ici>

On 2011-10-10 1:37, Yannick Duchêne (Hibou57) wrote:
> Welcome Jinsong :-)
>
> Le Sun, 09 Oct 2011 18:20:53 +0200, Jinsong Zhao <jszhao@yeah.net> a écrit:
>> When I using Ada, I don't know how to do. There are procedure,
>> function, package, package body, and so on (with different file
>> extension, e.g., ada, adb, ads, ...). And there is no main program.
> *.ada is not that common. Where did you see it ? *.adb and *.ads are not
> Ada specific, these are GNAT specific instead. The Ada Reference Manual
> does not specify file layout, nor file extensions.

Oops, I have seen *.ada somewhere, but I don't recall it...

>
> So this all depend on your compiler, which is GNAT here it seems (you
> may also have a look at Janus Ada from RRSoftware, if Ada 95 is enough
> for you).
>
> The file layout for GNAT is as this:
> Package specification in *.ads files
> Package body in *.adb
> Main procedure in *.adb
> Separate body in *.adb
>
> In few words: specifications goes to *.ads, which stands for Ada
> Specification, and implementations goes to *.adb, which stands for Ada
> Body.
>
> File names (not extensions) must be derived from compilation unit names,
> with this transformation applied: all uppercase characters turned into
> lowercase and periods turned into dashes.
>
> Example: your have a package name My_AI_Lib.Knowledge (to say we play
> with fun things). Then the specification will be in
> my_ai_lib-knowledge.ads, the body will be in my_ai_lib-knowledge.adb. If
> your test main program is a procedure named Test_My_AI, then it will
> belong to a file named test_my_ai.adb
>
> Similar things applies with separate bodies and child packages.
>
> Worth to read at your stage:
> http://www.adacore.com/wp-content/files/auto_update/gnat-unw-docs/html/gnat_ugn_2.html
>

Yes, I use GNAT as the compiler. However, I didn't find a way to obtain 
those information before I post and get help here.

>
>> Would anyone here like to give a an analogy between the source code
>> organization in Fortran and the one in Ada?
> Unless you use separate bodies all over the place, there is no way to
> compare Ada layout and Fortran layout. With Ada, multiple procedure may
> belong to a single package. May be there exist some compiler which
> requires each procedure to reside in its own file, but GNAT don't use
> such a layout. Keep in mind this is compiler specific!

There is many difference between the Ada layout and Fortran layout, 
however, I just have some experiences in Fortran. I will try my best to 
do something similar with the Ada style.
>
>> And, please, if you like, point me a small, complete open source
>> software in Ada (not a library or package). I should be compiled and
>> run. I just hope to learn how to start a software in Ada by example.
> I did not checked all of it, but here is a good list of samples (there
> may be some others too):
> http://sandbox.mc.edu/~bennet/ada/examples/

Yes it's a good place for learn Ada from piece of Ada sample code.

>
>> Any suggestions or comments will be really appreciated. Thanks in
>> advance.
> Yes, start with this:
>
>>>>
> -- Hello World, the quick easy form.
>
> with Ada.Text_IO; use Ada.Text_IO;
>
> procedure Hello is
> begin
> Put_Line ("Hello, Bonjour, Ohayo");
> end;
>>>>
>
> Second alternative, for people who enjoy to be more formal or strict:
>
>>>>
> -- Hello World, the proud form (lol).
>
> with Ada.Text_IO;
>
> procedure Hello is
> package IO renames Ada.Text_IO;
> Greeting_Message : constant String := "Hello, Bonjour, Ohayo";
> begin
> IO.Put_Line (Greeting_Message);
> end Hello;
>>>>
>
>> Regards,
>> Jinsong
> Have a nice time Jinsong
>
Thank you very much for your kind help.

Regards,
Jinsong





  reply	other threads:[~2011-10-10  6:02 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-09 16:20 how to organize source code for a complete software? Thanks! Jinsong Zhao
2011-10-09 17:16 ` stefan-lucks
2011-10-10  5:52   ` Jinsong Zhao
2011-10-09 17:37 ` Yannick Duchêne (Hibou57)
2011-10-10  6:02   ` Jinsong Zhao [this message]
2011-10-10 13:15     ` Paul Colin Gloster
2011-10-10 15:46       ` Simon Wright
2011-10-10 19:03       ` RasikaSrinivasan@gmail.com
2011-10-10 22:12       ` Randy Brukardt
2011-10-09 17:48 ` Niklas Holsti
2011-10-09 18:37   ` Ludovic Brenta
2011-10-09 21:24     ` J-P. Rosen
2011-10-10 12:09     ` Jinsong Zhao
2011-10-10  6:45   ` Jinsong Zhao
replies disabled

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