comp.lang.ada
 help / color / mirror / Atom feed
From: anon@anon.org (anon)
Subject: Re: Learning Ada
Date: Mon, 06 Jul 2009 02:50:20 GMT
Date: 2009-07-06T02:50:20+00:00	[thread overview]
Message-ID: <MDd4m.102020$d36.71108@bgtnsc04-news.ops.worldnet.att.net> (raw)
In-Reply-To: h2rgg8$blq$1@online.de

Wrong!
--
--  Just to show how easy it is redefining an Integer. Or the 
--  Standard package.  Compiled with GNAT < 2010 
--
with Ada.Text_IO ;
with Standard ; -- require for redefining Standard package

procedure Temp is

  use Ada.Text_IO ;

begin

  declare 

    package Integer_IO is new
                          Ada.Text_IO.Integer_IO ( Integer ) ;
    use Integer_IO ;

  begin
      New_Line ;
      Put_line ( "Integer predefined limits" ) ;
      Put ( "Range => ( " ) ;
      Put ( Integer'First ) ;
      Put ( " .. " ) ;
      Put ( Integer'Last ) ;
      Put_Line ( " ) " ) ;
      New_Line ;
  end ;

  --
  -- Now redefine the type Integer.
  --
  declare 
 
    type Integer is range -2 ** 8 ..  2 ** 8 - 1  ;

    package Integer_IO is new Ada.Text_IO.Integer_IO ( Integer ) ;
    use Integer_IO ;

  begin
      New_Line ;
      Put_line ( "Integer redefined limits" ) ;
      Put ( "Range => ( " ) ;
      Put ( Integer'First ) ;
      Put ( " .. " ) ;
      Put ( Integer'Last ) ;
      Put_Line ( " ) " ) ;
      New_Line ;
  end ;

  --
  -- Using a new Standard package
  --

  declare 

    package Integer_IO is new
                          Ada.Text_IO.Integer_IO ( Standard.Integer ) ;
    use Integer_IO ;

  begin
      New_Line ;
      Put_line ( "Integer limits from a new Standard package" ) ;
      Put ( "Range => ( " ) ;
      Put ( Standard.Integer'First ) ;
      Put ( " .. " ) ;
      Put ( Standard.Integer'Last ) ;
      Put_Line ( " ) " ) ;
      New_Line ;
  end ;
end Temp ;


--
--  This will compile under current GNAT < 2010.  Package cut down 
--  because the complete version is too long and is not needed to 
--  make the point. But all other types and operations will fall back to 
--  GNAT built-in Standard package aka for GNAT its universal Standard
--  package.
--
package STANDARD is 

  -- The universal type universal_integer is predefined.  

  type INTEGER is range - 2 ** 63 .. ( 2 ** 63 ) - 1 ;

end STANDARD ; 


In <h2rgg8$blq$1@online.de>, Albrecht =?ISO-8859-1?Q?K=E4fer?= <albrecht_kaefer@yahoo.de> writes:
>anon schrieb:
>>         But some people like "Ludovic Brenta, state that most Ada programmers
>> would prefer to create their own types. In some case, that goes against the RM
>> because it can create a non-standardize form of an Ada programs, that violate
>> other RM rules.
>
>It would be really smashing if you could provide some sort of proof for
>this bold claim.
>
>> Plus, the RM states that a number of numeric types are
>> predefined, such as "Integer", and it subtypes "Natural" and "Positive" as
>> well the type "Float" and its subtypes.
>> Redefining those predefines types are
>> legal in Ada, by simply re-defining the type.
>
>.... no? Standard.Integer et al cannot be redefined. You can change the
>underlying compiler, but then you could also change "begin" to "start".
>
>> Like for example, using 24 bit integer:
>>
>>     type Integer is range -2 ** 24 .. +2 ** ( 24 - 1 ) ;
>>
>> To use this new definition of "Integer", globally it needs to be define in the
>> standard package,
>
>Now how would you go around doing that?
>
>> but for a single package or routine it better to create a new
>> type or subtype and for the routine or package. But in most programming this
>> is not necessary. That is, since Ada creation and the DOD dropping it full
>> support of Ada, the usage for redefining the numeric data types is almost nil,
>> not the norm any more.  Plus, the DOD require full documentation on all new
>> define types.
>
>Why should we care about what the DoD requires again?
>
>>         Now, "Rob Solomon" stated that he think "it would be beneficial, if
>> the types Float and Integer were removed from the language".
>
>That is a personal opinion, not a law of nature.
>
>>         Second, the predefined types allow for the program to be more portable,
>> because a users type might not be accepted on the new system. But using the
>> standards or creating a subtype from the standards is better. An example is:
>>
>>     type Integer is range -2 ** 256 .. +2 ** ( 256 - 1 ) ;
>>
>> which is a valid Ada statement but in a 32-bit and most 64-bit system this
>> type is not allowed.
>
>There's nothing stopping you from creating a special Ada compiler
>supporting arbitrary-length integers.
>
>
>Albrecht




  reply	other threads:[~2009-07-06  2:50 UTC|newest]

Thread overview: 152+ 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
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 [this message]
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
  -- strict thread matches above, loose matches on Subject: below --
2020-09-15 10:36 Learning Ada Jack Davy
2020-09-15 14:31 ` Anders Wirzenius
2020-09-15 15:07   ` Jack Davy
2020-09-15 15:54     ` Ludovic Brenta
2020-09-15 17:01 ` Simon Wright
2020-09-15 17:07   ` Simon Wright
2020-09-15 19:03     ` Jack Davy
2020-09-15 19:28       ` Gautier write-only
2020-09-15 23:00       ` Jerry Petrey
2020-09-16  1:23       ` Paul Rubin
2020-09-16  7:13         ` Jack Davy
2020-09-16  7:32           ` Jack Davy
2020-09-16  9:13           ` Gautier write-only
2020-09-16 10:55           ` Ludovic Brenta
2020-09-16 11:09             ` Dmitry A. Kazakov
2020-10-02 18:43               ` gautier...@hotmail.com
2020-10-03  6:43                 ` Dmitry A. Kazakov
2020-10-05 18:36                   ` Shark8
2020-10-17 19:28                   ` antispam
2020-10-17 22:47                     ` Randy Brukardt
2020-10-18  6:45                       ` Dmitry A. Kazakov
2020-09-16 15:01           ` Jeffrey R. Carter
2020-09-18  6:53             ` Mart van de Wege
2020-09-18 10:00               ` Jeffrey R. Carter
2020-09-16 21:29           ` Paul Rubin
2020-10-06  4:06           ` andrew...@gmail.com
2020-10-06  7:32             ` Jack Davy
2020-10-17 23:02               ` mgr
2020-10-22 10:32                 ` Jeffrey R. Carter
2010-07-24 14:21 Frederick Williams
2010-07-24 16:21 ` Simon Wright
2010-07-25 20:33 ` mockturtle
     [not found] <36841f24.293012@news.ptd.net>
1998-12-25  0:00 ` learning ada LeakyStain
1998-12-26  0:00   ` David Botton
1989-06-15  1:48 Learning ADA Krishan M Nainani
1989-06-15 14:19 ` Rosa Weber
1985-09-06 15:10 Learning Ada Marty Sasaki
     [not found] <332@harvard.UUCP>
1985-09-04 16:07 ` richw
1985-09-03  2:46 Marty Sasaki
replies disabled

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