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!news2.google.com!news4.google.com!feeder.news-service.com!aioe.org!.POSTED!not-for-mail From: =?utf-8?Q?Yannick_Duch=C3=AAne_=28Hibou57?= =?utf-8?Q?=29?= Newsgroups: comp.lang.ada Subject: Re: how to organize source code for a complete software? Thanks! Date: Sun, 09 Oct 2011 19:37:07 +0200 Organization: Ada @ Home Message-ID: References: NNTP-Posting-Host: Ipxe1h/9XpCY+RzAEnnurg.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Content-Transfer-Encoding: Quoted-Printable X-Complaints-To: abuse@aioe.org User-Agent: Opera Mail/11.51 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 Xref: g2news2.google.com comp.lang.ada:22310 Date: 2011-10-09T19:37:07+02:00 List-Id: Welcome Jinsong :-) Le Sun, 09 Oct 2011 18:20:53 +0200, Jinsong Zhao a =C3= =A9crit: > When I using Ada, I don't know how to do. There are procedure, functio= n, = > 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. So this all depend on your compiler, which is GNAT here it seems (you ma= y = 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 wi= th = 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 i= s = 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/g= nat_ugn_2.html > 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 su= ch = a layout. Keep in mind this is compiler specific! > 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 m= ay = be some others too): http://sandbox.mc.edu/~bennet/ada/examples/ > 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 :=3D "Hello, Bonjour, Ohayo"; begin IO.Put_Line (Greeting_Message); end Hello; >>> > Regards, > Jinsong Have a nice time Jinsong -- = =E2=80=9CSyntactic sugar causes cancer of the semi-colons.=E2=80=9D [Ep= igrams on = Programming =E2=80=94 Alan J. =E2=80=94 P. Yale University] =E2=80=9CStructured Programming supports the law of the excluded muddle.= =E2=80=9D [Idem] Java: Write once, Never revisit