comp.lang.ada
 help / color / mirror / Atom feed
From: Mace Ayres <mace.ayres@gmail.com>
Subject: Re: Why *.adb and *.ads?
Date: Mon, 1 Jan 2018 17:50:29 -0800 (PST)
Date: 2018-01-01T17:50:29-08:00	[thread overview]
Message-ID: <349323e9-8458-4115-b3ec-e619c6d20d3c@googlegroups.com> (raw)
In-Reply-To: <p2e7i2$pde$1@dont-email.me>


Andrew, you may think of the *.abs and *.abb as source code in the tradition way. The *.ads is the speficition (the ‘s’ of ads) file, which specifies the sub programs (functions, procedures) types, and other components of the (package). 
The corresponding *.adb is the full body, elaborated, details of the specifications (promise of functions, procedures, types, etc.) specified in the *abs specification. 

This provides rigorous delivery of the abstraction aspect of Ada. Think of hiring a very reliable consultant to build x, which will do various things in a safe and reliable way. The contract you sign promises the WHAT of what will be delivered, the specifications in the *abs file. The contractor plans, schedules, gather resources and supervises the delivery of the specification. He is the *adb, the actual work that is done.

You don’t need to see all the details of how the work is done. In fact you, or other components of the overall program, don’t want to know. If the contractor uses Bob instead of Alice to do part of x, you don’t care as long the the specification of delivery remains consistent. 


—— Psuedo code,, not clean Ada syntax
test.abs .. 
procedure say_hello (message :string in);
procedure dubs. ...;
function example ....  ;
end test;  — speficiation 

test,adb ———————- 
Procedure say_hello is 
Begin 
put_line(message); 
end; — say_hello

function example (,,,, return string) 
begin
 return (“I am not ready yet.”)
end example;

end test.  — dbody 

to use procedue say_hello somewhere, I have” 
If happy then 
  say_hello (“i am happy”); 

else 
  say_hello(“Not so happy”); 
end if; 

If I code:
bucket := example;
put (bucket);
 I see there is a contract for a function called exaple that returns a string. It’s nothing yet, but I can later elaborate functionality of example without changing the ingterface. If I change the interface *.ads specification I have to change the body’s ingterface to match in the adb file too.
The details of the implementation of say_hello may change in the body *.adb, as long as the procedure definition in the *.abs and *adb domain the same. 

t

  reply	other threads:[~2018-01-02  1:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-01 20:15 Why *.adb and *.ads? Andrew Shvets
2018-01-01 21:00 ` Jeffrey R. Carter
2018-01-02  1:50   ` Mace Ayres [this message]
2018-01-02  1:27 ` Mace Ayres
2018-01-27 15:45 ` Norman Worth
2018-01-27 16:37   ` Dennis Lee Bieber
2018-01-27 22:18     ` [OT] VMS editors and PC keyboards, was: " Simon Clubley
2018-01-27 16:40   ` Mace Ayres
replies disabled

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