4 ms·
The attribute mechanism is something a lot of languages would benefit from. Need to know the maximum value of an integer? Just ask the integer type to tell you.
by kevin_thibedeau 12y ago
The attribute mechanism is something a lot of languages would benefit from. Need to know the maximum value of an integer? Just ask the integer type to tell you. No going to a library to look up inscrutable constants.
- cjensen 12y agoC++: numeric_limits<type>::max ()
- kevin_thibedeau 12y agoAda attribute provide a lot more meta information about types and objects than just integer limits. http://en.wikibooks.org/wiki/Ada_Programming/Attributes http://en.wikibooks.org/wiki/Ada_Programming/Attributes Some of these would be methods in modern OO languages but many are unique to Ada.
- cjensen 12y agoSo does C++; both C++ and Ada have traits the other doesn't. Good ideas go around.
- jmnicolas 12y agoIn C# you have Int32.MaxValue. I always assumed it was pretty standard everywhere. Btw, Ada is on my list of languages to learn since 2011. I guess I will put it first on the 2015 good resolutions list :-)
- claystu 12y agoWhen you get started, here are the two books that seem to get recommended the most frequently: Ada as A Second Language: http://amzn.com/0070116075 http://amzn.com/0070116075 Programming in Ada 2005: http://amzn.com/0321340787 http://amzn.com/0321340787
- jmnicolas 12y agoThanks, I didn't know the first book but the second one has a more recent version covering Ada 2012.
- claystu 12y agoInteresting, I didn't realize there is a new edition: Programming in Ada 2012 by John Barnes: http://amzn.com/110742481X http://amzn.com/110742481X I wonder if ADA wouldn't be better if they were subtracting features rather than adding them.
- cjensen 12y agoI have an old copy of 'Ada as A Second Language'. It's like a million pages. A second language handbook shouldn't be thicker than K&R. Do you know any short books that really assume I already know how to program?
- claystu 12y agoI don't know of any short books on Ada. Given the language, and the fact it's still growing, I doubt there are any.
- krylon 12y agoThere is a Wikibook on Ada, although I cannot say anything about its quality. Also, the Ada language standard and the rationale document are available for free. The standard is really more useful as a reference document, but it is surprisingly readable for a standards document.
- kazagistar 12y agoIn Haskell, you have typeclass values. In other words, generic values. class Bounded a where minValue, maxValue :: a So it is always the same constant, and it just changes value by what its type context is.