If any Ada users are here, I have question on one section: procedure Main is type Distance is new Float; type Area is new Float; D1 : Distance := 2.0; D2 : Distance := 3.0; A : Area; begin D1 := D1 + D2; -- OK D1 := D1 + A; -- NOT OK: incompatible types for "+" operator A := D1 * D2; -- NOT OK: incompatible types for ":=" assignment A := Area (D1 * D2); -- OK end Main; > The predefined Ada rules are not perfect; they…
There is now, at least with Ada 2012 and GNAT[0][1]. While I'm pretty sure only GNAT has implemented it, I'm not sure if it's actually in the 2012 standard or not. I haven't played with it yet, but it does looks pretty interesting. [0] https://gcc.gnu.org/onlinedocs/gcc-4.9.4/gnat_ugn_unw/Perfor... [1] https://blog.adacore.com/uploads/dc.pdf
Ada for the C++ and Java Developer [pdf]
21–30 of 72 posts
Re: Ada for the C++ and Java Developer [pdf]
#22Earlier quoted context omitted.
Accesses - pointers - are automatically nulled when declared. So you won't silently screw up who-knows-what with an uninitialized access, though yeah, it's not perfectly safe.
I didn't mean pointers/access-types, I meant ordinary integer-type locals.
Other compilers have similar switch.
Heck even C and C++ have them, although few make use of them.
Re: Ada for the C++ and Java Developer [pdf]
#23I used Ada (first Ada95, later Ada2005) while working on the GPS program, before leaving aerospace and taking on work using Java. I found the Java type system to be horrendous in comparison. Much better employment potential, though...
Although Turbo Pascal isn't Ada, it did allow for a similar approach with stronger types, which C++ also kind of supports (but C compatibility spoils it).
Re: Ada for the C++ and Java Developer [pdf]
#24Re: Ada for the C++ and Java Developer [pdf]
#25Re: Ada for the C++ and Java Developer [pdf]
#26Earlier quoted context omitted.
I didn't mean pointers/access-types, I meant ordinary integer-type locals.
You can put a pragma Warning_As_Error (" never assigned "); or the respective compiler switch on GNAT. Other compilers have similar switch. Heck even C and C++ have them, although few make use of them.
And if you can afford it, Codepeer (static analysis) finds most of the ones the compiler doesn't find. And then if you can live with the Spark subset, you get proof of initialization in 'bronze' mode :-).
Re: Ada for the C++ and Java Developer [pdf]
#27Earlier quoted context omitted.
I didn't mean pointers/access-types, I meant ordinary integer-type locals.
You can put a pragma Warning_As_Error (" never assigned "); or the respective compiler switch on GNAT. Other compilers have similar switch. Heck even C and C++ have them, although few make use of them.
I'm not sure if it lets you shoot yourself in the foot regarding invalid type conversions, misuse of unions, that kind of thing.
Re: Ada for the C++ and Java Developer [pdf]
#28Ada seems like a really good language. Is there any reason why it isn't more popular?
Re: Ada for the C++ and Java Developer [pdf]
#29Ada seems like a really good language. Is there any reason why it isn't more popular?
Why Ada isn't Popular (1998): https://news.ycombinator.com/item?id=7824570