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.8 required=5.0 tests=BAYES_00,FREEMAIL_FROM, PLING_QUERY autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,2f6e39a9d25bcd8b X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,UTF8 Path: g2news2.google.com!news3.google.com!feeder.news-service.com!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Jinsong Zhao Newsgroups: comp.lang.ada Subject: Re: how to organize source code for a complete software? Thanks! Date: Mon, 10 Oct 2011 14:02:51 +0800 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Mon, 10 Oct 2011 06:02:53 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="E9kds4mxpUa8gjsIwoqDZw"; logging-data="20690"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ONKvpVSz8FCtREMIlz0en" User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 In-Reply-To: Cancel-Lock: sha1:6rJoBdKZM1WgcA0BVWB9EsKYB9c= Xref: g2news2.google.com comp.lang.ada:22315 Date: 2011-10-10T14:02:51+08:00 List-Id: On 2011-10-10 1:37, Yannick DuchĂȘne (Hibou57) wrote: > Welcome Jinsong :-) > > Le Sun, 09 Oct 2011 18:20:53 +0200, Jinsong Zhao 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