โŒ About FreshRSS

Normal view

There are new articles available, click to refresh the page.
Before yesterdayNews from the Ada programming language world

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

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.

Ada: subprogram that ignores initial blank spaces

I'm interested in finding out if there is a way to create a "Get" subprogram for strings that works like "Get" for Integers or Float. As I understand the Ada get procedure for Integers ignores any type in of blank spaces before the integer and only collects the integer value.

Let's say we want to collect a string of five characters that should be stored in the variable "S" but the user type in 10 blank spaces and then the string so it would look something like this: Put in a string of 5 characters: buses I would like to create a "Get" that ignore these blank spaces and only gives my program the string value of 5 characters.

This is my main program.

S : String (1 .. 5);
begin
Put("Put in a string of 5 characters: ");
Get(S);
Put_Line(S);

I've read something about a function End_Of_Line. I understand that i need to create some kind of subprogram that collects the string and skips all initial blank spaces but I have not come up with a working solution.

Update: I tried to create my own get but got a little bit stuck. The get procedure should read the next character if the previous is ' ' but if it reads "the correct" string, how should the code look like?

       procedure Get(Item : in out String) is
      
      Ch : Character;
   begin
      
      loop
     Get(Ch);
     if Ch = ' ' and (not End_Of_Line) then
        Get(Ch);
     else 
       exit;
     end if;
      end loop;
      
   end Get;
โŒ
โŒ