comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.acm.org>
Subject: Re: Learning Ada but missing the basics?
Date: Mon, 30 Jun 2008 21:48:07 GMT
Date: 2008-06-30T21:48:07+00:00	[thread overview]
Message-ID: <rwcak.178626$TT4.88710@attbi_s22> (raw)
In-Reply-To: <85e95c57-07c3-42eb-b9b9-eac5fd3d0d65@i76g2000hsf.googlegroups.com>

ryan k wrote:
> I'm trying to learn Ada because a) I think it's cool to learn new
> computer languages and b) it looks like a good one. I've gone the
> through a lot of the tutorials but lets say have package MyPackage and
> 5 subprograms are in the body. Which procedure is run first? Is it
> sequential? Is there some sort of equivalent to C's main()? Is a
> binary created for every package? I guess I don't understand where
> things start and end. Any help or links are greatly appreciated!

You've clearly missed something.

Ada is a concurrent language; this answer assumes you haven't created any tasks.

The thread of control in an Ada program is called the environment task. It 
performs elaboration and initialization as needed, calls the main-program 
procedure, and finally performs any finalization that's needed.

The main-program procedure is one that you designate during the building of the 
executable.

Subprograms in packages are only "run" if they're called.

Consider the typical hello-world example:

with Ada.Text_IO;

procedure Hello is
    -- null;
begin -- Hello
    Ada.Text_IO.Put_Line (Item => "Hello, World!");
end Hello;

Here, procedure Hello is the main-program procedure. You indicate that when 
building the executable. For instance, with GNAT you would put it in a file 
named hello.adb and might say

gnatmake -gnato -fstack-check -O1 hello

which will create an executable named hello[.platform-dependent-extension].

Ada.Text_IO is a package which contains a number of subprograms. In this 
example, we call its procedure Put_Line. Put_Line may call other subprograms in 
Ada.Text_IO or in other packages. These are the only subprograms that are "run".

HTH.

-- 
Jeff Carter
"Your mother was a hamster and your father smelt of elderberries."
Monty Python & the Holy Grail
06



  parent reply	other threads:[~2008-06-30 21:48 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-30 19:01 Learning Ada but missing the basics? ryan k
2008-06-30 20:19 ` Keith Thompson
2008-06-30 20:38   ` ryan k
2008-06-30 21:18     ` mockturtle
2008-06-30 21:48 ` Jeffrey R. Carter [this message]
2008-07-01  1:15   ` ryan k
2008-07-01  2:56     ` Tero Koskinen
2008-07-01  3:13     ` Jeffrey R. Carter
2008-07-02  3:02     ` DScott
2008-07-02  9:18     ` Pascal Obry
2008-07-02 15:54       ` Alex R. Mosteo
2008-07-02 17:17         ` Georg Bauhaus
2008-07-03  8:09           ` Alex R. Mosteo
2008-07-04 17:08         ` Simon Wright
2008-07-04 17:39           ` Pascal Obry
2008-07-08  8:23           ` Alex R. Mosteo
2008-07-08  9:47             ` Jean-Pierre Rosen
2008-07-02 17:47     ` Gautier
2008-07-01 20:51 ` John McCormick
replies disabled

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