comp.lang.ada
 help / color / mirror / Atom feed
From: mike@zin.world.com
Subject: A note on Ada subtyping
Date: 1999/02/22
Date: 1999-02-22T00:00:00+00:00	[thread overview]
Message-ID: <7asf3h$9gm@drn.newsguy.com> (raw)


As I am learning Ada (I use the GNAT compiler, an
excellent compiler btw), I am more impressed with it.

This is one simple example, where Ada helped me find a bug
in my logic that I would not been able to find as easily
if I was using C or C++ or even Java.

I needed a variable, that logically could not take in values
over some range, say n..m, becuase this is the nature of
the problem was. So I defined this variable to be
of of this type. (where in C/C++/Java, I would simply have
made it an 'int' or a 'short' as almost eveyone else would have),
giving the variable a much larger range that is really needed.

During running of the program, the Ada run-time generated a 
contraint error exception as soon the program tried to
assign a value to this variable outside this range.

This quickly lead me to see where my logic error was, and I fixed
it.

This is an excelllent language. By using variables with restricted
ranges and values, as in this case, Ada helped me find a prblem in
my logic!

Ada is giving me the power to write a more tight code thanks
to the ability to easily define types as required by the 
problem domain.

I know in the other languages, I would have missed this 
logic error, or at least it would have taken longer to find it.

Makes me wonder, why isn't the whole world programming in Ada?

Mike.




             reply	other threads:[~1999-02-22  0:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-02-22  0:00 mike [this message]
1999-02-22  0:00 ` A note on Ada subtyping Mike Silva
replies disabled

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