From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!news.glorb.com!wn13feed!worldnet.att.net!bgtnsc04-news.ops.worldnet.att.net.POSTED!53ab2750!not-for-mail Newsgroups: comp.lang.ada From: anon@anon.org (anon) Subject: Re: unsigned type Reply-To: anon@anon.org (anon) References: X-Newsreader: IBM NewsReader/2 2.0 Message-ID: Date: Mon, 29 Jun 2009 08:00:56 GMT NNTP-Posting-Host: 12.64.24.69 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc04-news.ops.worldnet.att.net 1246262456 12.64.24.69 (Mon, 29 Jun 2009 08:00:56 GMT) NNTP-Posting-Date: Mon, 29 Jun 2009 08:00:56 GMT Organization: AT&T Worldnet Xref: g2news2.google.com comp.lang.ada:6696 Date: 2009-06-29T08:00:56+00:00 List-Id: For Strings: -- 'A' is a zero length string, A'Last = 0, and -- put_line ( A ( A'First .. A'Last ) ) ; -- does not raise an Constraint_Error even though in -- this case it translate to: -- put_line ( A ( 0 .. 0 ) ) ; A : String := "" ; Since you can have zero length string , the index is Natual instead of Positive, because zero is in Natural but is not define in Positive. Even though the Standard package define String index as a Positive type. (GNAT) Always use standards, those who do not are the one making the mistakes that others must correct to make the program portable during updating. Because the user created type may not be useable on all processor, for both backward and upward compatibility. A SUBTYPE might be needed on a standard type is always available for upward portable. And a larger standard type can be available for backward compatibility. An example Backward system: Long_Integer ; -- 32 bit Integer on a 16 bit machine or type Integer is new Long_Integer ; Current system: Integer ; -- 32 bit system -- limit to 32 bit on a 64 bit system Upward system; subtype Integer is Standard.Integer range (2**32) .. (2**32) -1 ; Major rewrite for 128-bit system. And since the death of PUNCH CARDS there should be no Style, except for RPG. This is echoed as hard drives sizes have increase with lower prices. And size of the object modules does not change if one uses style or not in the source code. Or adds a single line comment or a book length comment section. Plus, using the Ada style either 83 or 95 (absent 2005/7) version makes the source code unreadable. And also there is no longer any DOD requrement to use the Ada Style Guides. Plus, style is someone's way of creating only one way of programming and that might get into patents infringement for all programmers. So, never use a predefine style except for your own guidelines. Finally, most programs will last about 2 CPU generations, before the program requires a major rewrite. An example is AT&T original OS, even though one can still compile the C version programs, the I/O and driver drivers would never works on todays system. Todays hardware is incompatable with the older drivers. Note: Pentium 1 thru the current Core 2 series are all based on the 6th intel generation. Core i7 is the 7th Intel generation and is mostly compatibility with Intel 6th generation cpu. And during initial startup or real mode, it is still compatibility with the 8088/8086 series cpu. But most 80286/80386 code using protective mode must have a major rewrite if updating to use the Core 2 dual/quad or Core i7. In , tmoran@acm.org writes: >> And as for Natural, well, that is the definition of a String's index > false. >> and in most cases you use Naturals in "for loop' statements. > false. > >> And if you use the standard types instead of creating your own you >> would save problem when another modifies the program! > unlikely. > >> Alway use standard if possible, > Most experienced Ada programmers would say the opposite. > >> That way every program rather Ada or C or etc known the type >> and the range. > false. I can't count the number of times I had to change a >program that assumed that, say, the standard type Integer was 32 bits. >(And almost never was it reasonable for a variable of the type in >question to have a value of plus or minus a couple of billion.) > >> Never create your own types unless lives are an issue. > Most Ada programmers would say your programs are more likely to be >correct if you welcome, rather than refuse, assistance from the compiler. >If you define your own types, the compiler can check that you aren't >erroneously adding Number_Of_Apples to Miles_Travelled, and that >Miles_Travelled is within the reasonable range you specify (not just >+- 2**32). If you use a particular compiler version's standard Integer, >who knows if it will be the same 3 CPU generation later when your code is >still in use and you have long since left that project. > >A good Ada style guide is >http://www.adaic.org/docs/95style/95style.pdf