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=-0.2 required=5.0 tests=BAYES_00,PLING_QUERY, REPLYTO_WITHOUT_TO_CC 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: g2news2.google.com!news3.google.com!feeder.news-service.com!feeder.erje.net!news-1.dfn.de!news.dfn.de!news.uni-weimar.de!not-for-mail From: stefan-lucks@see-the.signature Newsgroups: comp.lang.ada Subject: Re: how to organize source code for a complete software? Thanks! Date: Sun, 9 Oct 2011 19:16:33 +0200 Organization: Bauhaus-Universitaet Weimar Message-ID: References: Reply-To: stefan-lucks@see-the.signature NNTP-Posting-Host: medsec1.medien.uni-weimar.de Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: tigger.scc.uni-weimar.de 1318181181 27040 141.54.178.228 (9 Oct 2011 17:26:21 GMT) X-Complaints-To: news@tigger.scc.uni-weimar.de NNTP-Posting-Date: Sun, 9 Oct 2011 17:26:21 +0000 (UTC) X-X-Sender: lucks@medsec1.medien.uni-weimar.de In-Reply-To: Xref: g2news2.google.com comp.lang.ada:22309 Date: 2011-10-09T19:16:33+02:00 List-Id: > 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. > 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: 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. -- ------ Stefan Lucks -- Bauhaus-University Weimar -- Germany ------ Stefan dot Lucks at uni minus weimar dot de ------ I love the taste of Cryptanalysis in the morning! ------