comp.lang.ada
 help / color / mirror / Atom feed
* A note on Ada subtyping
@ 1999-02-22  0:00 mike
  1999-02-22  0:00 ` Mike Silva
  0 siblings, 1 reply; 2+ messages in thread
From: mike @ 1999-02-22  0:00 UTC (permalink / 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.




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1999-02-22  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-02-22  0:00 A note on Ada subtyping mike
1999-02-22  0:00 ` Mike Silva

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