0

fellow coders..

I'm just a new learner and try to practice some programming paradigms in their specific designed environments. Recently I've learn quite many new small things in Procedural Programming in Ada Language and have a great experience of learning. But, I cannot find the answer by myself for the wonder why Ada does use Semicolons ; to separate Parameters in Subprogram Declarations.

-- subprogram declaration - - - - - - - - -

procedure Initialize_Some_Things
   ( Result : out Integer
   ; Asset : in Integer
   ; Option: in Integer ) is
begin
   null;
end Initialize_Some_Things;

-- invoking subprogram - - - - - - - - -

Instance : Integer := 0;
Initialize_Some_Things (Instance, 9, 5);

It's obviously strange for anyone who comes from any other programming language to use a Semicolon to Separate Parameters in Subprogram Declaration though. And it's even more strange when the Invocations of Subprograms require to use Comma , instead of Semicolon ; as in Declarations. I've searched for related questions for sometime and find nothing on the Google. Is there anyway to submit a request to make this subtle change to the standard specification of the language?

I've found no related question on Google. And I hope I can find here.

Semi Dev_
  • 31
  • 2
  • As Ada was influenced by Pascal, see [_semicolon use_](https://en.wikipedia.org/wiki/Comparison_of_Pascal_and_C#Semicolon_use). – trashgod Dec 21 '22 at 16:42
  • It is probably no longer relevant for this question, but for the record: you can make suggestions for Ada language changes, and other comments or requests, at https://arg.adaic.org/community-input. – Niklas Holsti Dec 21 '22 at 18:49
  • CORAL66 used semicolons in exactly the Ada way. – Simon Wright Dec 21 '22 at 21:32

1 Answers1

5

You do separate parameters in a list with a comma, but you separate lists with semicolon; the different symbol helps catch errors.

In your testcase, each of those entries is a list of parameters, not a parameter. You chose to make three lists, each one item long, but you could have combined two of those lists into one, and used a comma.

Asset, Option : In Integer

It's mainly a matter of style to help clarity.

If Asset and Option are very different things, different lists help clarify the distinction. If they are similar like X,Y,Z in a Cartesian coordinate, I would combine them into one list.

Yes it may be strange for a programming language to place so much emphasis on writing clear code.

Another example: it's often seen as better practice to call this subprogram with named association

Initialize_Some_Things (Result => Instance, 
                        Asset  => 9,
                        Option => 5);

If you've ever spent a happy afternoon chasing a bug that turned out to be a couple of parameters in the wrong order, you may find this style of Ada disappointingly predictable.

  • Oh.. I got it now. It's just because Ada allows to shorten the declaration by grouping parameters into Lists categorized by data type. Thanks for your answer. – Semi Dev_ Dec 21 '22 at 17:49
  • Data type, mode (in, out etc) and optional default value, but yes. –  Dec 21 '22 at 22:19