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,ASCII-7-bit Path: g2news1.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 13:52:38 +0800 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 10 Oct 2011 05:52:43 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="E9kds4mxpUa8gjsIwoqDZw"; logging-data="17939"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/YeyLZ+dDwL2SwAhW9VqQF" 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:wvzydJm4JH8DwE2JsX0n2p/igY4= Xref: g2news1.google.com comp.lang.ada:21343 Date: 2011-10-10T13:52:38+08:00 List-Id: On 2011-10-10 1:16, stefan-lucks@see-the.signature wrote: >> I am new to Ada, and I just have some experiences in using Fortran. >> >> When using Fortran, I generally put each subroutine or function in a separate >> file, e.g., dot.for for dot product of two vectors. Then a main.for that call >> the necessary subroutine or functions. It seems to be rational. >> >> 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. > > 1. Any parameterless procedure, which is not "local" inside another > function/procedure or inside a package, can be the main program. > > 2. As a rule of thumb for beginners: Put your auxiliary subprograms (in > Ada: a subprogram is either a function or a procedure) and the requited > type definition into packages. Write a single parameterless main > procedure as the "main" procedure, but give it a meaningful name > ("Solve_Linear_Equations" or "Delete_File" rather than "Main"). Put > that procedure into a file of its own. > > 2a. Note that a package consists of a specification and an implementation, > which are usually put into TWO different files (e.g., "name.ads" for > the spec and "name.adb" for the implementation body). > > 2b. When you are more advanced in programming in Ada, you may sometimes > want to compile "separate" subprograms without wrapping them into > packages. > > 3. Compile the main procedure (e.g., by calling "gnatmake" if you use the > gnat Ada compiler) -- your compiler will know which packages it needs > to compile. Thank you very much. The above statements give me more information than what I get from the books available to me here. Now, I think I know how to layout my small program. > >> 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. > > Examples: > > It's a nice place for me. Thanks! > > The linear congruential example would consist of three files: > 1. the specification "lcg.ads", > 2. the implementation "lcg.adb", and > 3. the main program "run_lcgs.adb". > (These are the gnat/gcc naming conventions, look into your compiler > documentation if you use another compiler.) > > As an easy exercise for the reader, try to figure out which three files > the ternary logic example would consist of. > > I think I can get the answer: 1. the specification "logic.ads", 2. the implementation "logic.adb", and 3. the main program "test_tri_logic.adb". Thanks again for your informative reply and the example codes. Regards, Jinsong