I am taking Ada in college. Today my professor posed a question to us. In the following bit of code there are three type declarations. The third one doesn't compile with an error 'missing new'.
I am assuming that the 'Type' keyword lets the compiler know that we are about define a storage class so my questions are:
what are the semantic differences between the declarations?
If the keyword Integer is omitted does Ada assume the universal integer type when the range is specified? This seems like an obvious and logical outcome. Furthermore when the keyword 'Integer' is before 'range' is new then required?
I hope this wasn't ambiguous, I did some research but can't seem to find an exact answer, or maybe i'm to much of a newbie with Ada to understand what I have found. I really would like to understand what is happening below.
with Ada.Text_IO; use ada.Text_IO;
procedure any is
type abc is new Integer range 1..10;
num : abc;
type def is range 1..10;
num2 : def;
type xyz is Integer range 1..10;
num3 : xyz;
begin
num := 5;
num2 := 6;
num3 := 7;
end any;