comp.lang.ada
 help / color / mirror / Atom feed
From: anon@anon.org (anon)
Subject: Re: unsigned type
Date: Mon, 29 Jun 2009 08:00:56 GMT
Date: 2009-06-29T08:00:56+00:00	[thread overview]
Message-ID: <Yw_1m.93774$d36.55288@bgtnsc04-news.ops.worldnet.att.net> (raw)
In-Reply-To: h2919r$8ua$1@aioe.org

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 <h2919r$8ua$1@aioe.org>, 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




  reply	other threads:[~2009-06-29  8:00 UTC|newest]

Thread overview: 113+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-28 15:36 unsigned type Rob Solomon
2009-06-28 15:45 ` Florian Weimer
2009-06-28 15:48 ` Albrecht Käfer
2009-06-28 17:56 ` anon
2009-06-28 19:17   ` Ludovic Brenta
2009-06-28 23:08     ` anon
2009-06-29  0:19       ` tmoran
2009-06-29  8:00         ` anon [this message]
2009-06-29  9:56           ` Jean-Pierre Rosen
2009-06-29 10:21             ` Ludovic Brenta
2009-06-29 11:23               ` sjw
2009-06-29 12:07                 ` Jean-Pierre Rosen
2009-06-29 20:06                 ` anon
2009-06-29 19:31               ` anon
2009-06-29 21:49                 ` Georg Bauhaus
     [not found]                 ` <zuKdneNYxfFNLNTXnZ2dnUVZ_t2dnZ2d@earthlink.com>
2009-06-30 11:29                   ` anon
2009-06-30 12:19                     ` Ludovic Brenta
2009-06-29 20:19             ` anon
2009-06-29 20:41               ` Ludovic Brenta
2009-06-29 22:15               ` Georg Bauhaus
2009-06-29 23:08               ` Adam Beneschan
2009-06-29 23:11               ` Adam Beneschan
2009-06-30 12:39               ` Martin
2009-06-29 10:25           ` Georg Bauhaus
2009-06-29 20:02             ` anon
2009-06-29 22:08               ` Georg Bauhaus
2009-06-30 23:01                 ` Randy Brukardt
2009-06-30 13:46               ` Jean-Pierre Rosen
2009-06-30 15:22                 ` Adam Beneschan
2009-06-30 15:59                   ` Albrecht Käfer
2009-06-30 16:59                     ` Adam Beneschan
2009-06-30 17:44                       ` Albrecht Käfer
2009-06-30 18:13                         ` Robert A Duff
2009-06-30 18:16                           ` Albrecht Käfer
2009-06-30 23:48                       ` anon
2009-07-01  1:39                         ` Adam Beneschan
2009-07-02 19:04                           ` anon
2009-07-02 19:49                           ` anon
2009-07-02 21:37                             ` Adam Beneschan
2009-07-03  1:42                             ` anon
2009-07-03  2:10                               ` Adam Beneschan
2009-07-03  7:07                             ` Jean-Pierre Rosen
2009-07-03 20:53                               ` anon
2009-07-03 21:24                                 ` Georg Bauhaus
2009-07-04  9:09                                   ` anon
2009-07-04 13:43                                     ` Georg Bauhaus
2009-07-06  9:04                                     ` AdaMagica
2009-07-03 21:46                                 ` Adam Beneschan
2009-07-04 12:39                                   ` Martin
2009-07-01  8:09                   ` Jean-Pierre Rosen
2009-07-01 15:08                     ` Albrecht Käfer
2009-07-11 14:40           ` Hibou57 (Yannick Duchêne)
2009-07-11 17:18             ` sjw
2009-07-11 18:15               ` Hibou57 (Yannick Duchêne)
2009-07-11 20:20             ` anon
2009-07-12 17:57               ` Samuel Tardieu
2009-07-12 18:24                 ` AdaMagica
2009-07-13 22:03                 ` anon
2009-07-14  7:58                   ` Martin
2009-07-16 13:54                     ` anon
2009-07-16 14:41                       ` Martin
2009-07-16 15:12                         ` Adam Beneschan
2009-07-11 14:43           ` Hibou57 (Yannick Duchêne)
2009-07-11 15:22             ` Albrecht Käfer
2009-06-29  8:42       ` Martin
2009-06-29  8:54         ` Dmitry A. Kazakov
2009-06-29 10:10           ` Martin
2009-06-29 12:34             ` Dmitry A. Kazakov
2009-06-29 19:26             ` anon
2009-06-29 23:02               ` Martin
2009-06-29 19:47           ` anon
2009-06-30  8:31             ` Ludovic Brenta
2009-06-28 19:54   ` tmoran
2009-06-28 22:34     ` Gary Scott
2009-06-28 23:15       ` John B. Matthews
2009-06-28 23:21       ` anon
2009-06-29  7:18       ` Dmitry A. Kazakov
2009-06-29  9:52         ` Georg Bauhaus
2009-06-29 12:43           ` Dmitry A. Kazakov
2009-06-29 13:36     ` Rob Solomon
2009-06-29 14:03       ` Robert A Duff
2009-06-29 14:13       ` Georg Bauhaus
2009-06-29 14:18       ` Ludovic Brenta
2009-06-29 15:40         ` Robert A Duff
2009-07-03  1:41         ` Rob Solomon
2009-07-03  7:12           ` Learning Ada (Was: unsigned type) Jacob Sparre Andersen
2009-07-03  8:38             ` Learning Ada Peter Hermann
2009-07-03  9:44               ` Georg Bauhaus
2009-07-03 22:20             ` Learning Ada (Was: unsigned type) anon
2009-07-04 14:53               ` Georg Bauhaus
2009-07-05 23:21                 ` anon
2009-07-06  0:05                   ` Ludovic Brenta
2009-07-06  0:19                   ` Learning Ada Albrecht Käfer
2009-07-06  2:50                     ` anon
2009-07-06  6:18                       ` AdaMagica
2009-07-06  7:47                         ` Jean-Pierre Rosen
2009-07-06 20:21                         ` anon
2009-07-06 21:08                           ` Georg Bauhaus
2009-07-06 22:43                           ` Frank J. Lhota
2009-07-09 22:28                             ` anon
2009-07-10  6:23                               ` AdaMagica
2009-07-06 10:53                   ` Learning Ada (Was: unsigned type) Georg Bauhaus
2009-07-06 19:34                     ` anon
2009-07-06 20:29                       ` Learning Ada Albrecht Käfer
2009-07-06 21:04                       ` Learning Ada (Was: unsigned type) Georg Bauhaus
2009-07-07 19:25                       ` sjw
2009-07-06 23:15                   ` Randy Brukardt
2009-07-07 15:29                     ` Adam Beneschan
2009-07-09  0:15                       ` Randy Brukardt
2009-07-09 15:26                         ` Adam Beneschan
2009-06-29 15:37       ` unsigned type Adam Beneschan
2009-07-06 20:20       ` Dave
2009-06-29 16:51 ` Martin Krischik
replies disabled

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