Why does Ada Language use Semicolon `;` to Separate Parameters in Subprogram Declarations?

149 Views Asked by At

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.

1

There are 1 best solutions below

2
AudioBubble On

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.