comp.lang.ada
 help / color / mirror / Atom feed
From: Ludovic Brenta <ludovic@ludovic-brenta.org>
Subject: Re: Learning Ada (Was: unsigned type)
Date: Sun, 5 Jul 2009 17:05:20 -0700 (PDT)
Date: 2009-07-05T17:05:20-07:00	[thread overview]
Message-ID: <134d9099-7384-4a76-a81b-4d8a2c6517c6@24g2000yqm.googlegroups.com> (raw)
In-Reply-To: 4Aa4m.421894$4m1.207252@bgtnsc05-news.ops.worldnet.att.net

anon top-posted on comp.lang.ada:
> Wrong!
>         I was not talking about the Ada Statements "Type" or "Subtype" but
> true Standards that go beyond Ada.

Please define a "true standard" (as opposed to a "standard") and what
it means for a "true standard" to "go beyond" Ada.  "go beyond" is a
non-standard phrase, it does not appear anywhere in the ARM.

[use the language-defined Integer and Float]
>         But some people like "Ludovic Brenta, state that most Ada programmers
> would prefer to create their own types.

I did not state that; I don't know what "most Ada programmers" do or
where they are, and I don't use the "lemming argument" because I
honestly don't care what "most people" do in general.  If I wanted to
do what "most people" do, I would not program in Ada.  What I said is
that it is generally *better* to use application-defined types than
language-defined types; this is the proper and intended way to use
Ada.

> 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.

If a program violates other RM rules and the compiler properly
enforces the rules, then the program won't compile.  What was your
point?

> 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. Like for example, using 24 bit
> integer:
>
>     type Integer is range -2 ** 24 .. +2 ** ( 24 - 1 ) ;

Wrong; your declaration is legal but it does not "redefine"
Standard.Integer; it defines a new type with the same name.

> To use this new definition of "Integer", globally it needs to be define in the
> standard package, but for a single package or routine it better to create a new
> type or subtype and for the routine or package.

No; it is better to define an application-specific type instead.  By
declaring a type Integer in your own package, you create a new problem
(global visibility of your new type) without solving any existing
problem, so this is not only useless but harmful.  I've seen it done
in several places before and the reasons given to me for doing that
were always wrong. At least they avoided using the name Integer but
used Integer_Type or something similarly stupid instead.  By the same
token, changing the definition of Standard.Integer achieves nothing
useful and is a lot of trouble, so don't do that.

> 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. And no matter what type is defined the compiler will fall back to the
> basic standards of the universal-integer and universal-real aka CPU integer
> and FPU float and their operations. If you study most of the implementations of
> Ada, one can see that the types "Integer" and "Float" that are defined in the
> "Standard" package are basically equivalent to the Ada's universal-integer and
> universal-real.

So what?  If you don't want compile-time type checks and only care
about the hardware-defined types, then go program in assembly
language.

>         Now, "Rob Solomon" stated that he think "it would be beneficial, if
> the types Float and Integer were removed from the language".

No, that was Jacob Sparre Andersen.

>         First, if this could happen the RM would need a MAJOR overhaul.
> It would be easier to create a new language. Because both types are used
> throughout the RM defined packages.
>
>         Second, the predefined types allow for the program to be more portable,
> because a users type might not be accepted on the new system.

I'm sure Jacob is well aware of that.  For your second objection, it
is a *Good* *Thing* if the compiler says up-front, at compile time,
whether it supports the application-defined types or not.  It is a
*Bad* *Thing* if the compiler is silent and the application later
misbehaves because the hardware doesn't support the application
constraints.

[...]
>         Then third, is without standards types like "Integer" and "Float" how
> would the system work.  Using Ada, define a "=" or "*" without using the
> universal-integer and universal-real types or there operations.  You can not!

You seem to be confusing the unioversal_integer and universal_real
types (which are anonymous) with Standard.Integer and Standard.Float,
respectively.  They are *not* the same things.  Even if
Standard.Integer and Standard.Float disappeared, unioversal_integer
and universal_real would still exist and allow the arithmetic
operations you describe.

[...]
>         Fourth, is to interface with other languages. which also use standards.
> Some Ada programmer prefer pure Ada code.  Like using the "Interface"
> package to only define the standard unsigned types and to use the low-level
> shift and rotate routines for those unsigned types. But there are times when
> interfacing is required.

For interfacing to C, you use Interfaces.C.int, not Standard.Integer,
and Interfaces.C.C_float, not Standard.Float.  For COBOL you use
Interfaces.COBOL.Binary and Interfaces.COBOL.Floating.  For Fortran,
you use Interfaces.Fortran.Fortran_Integer and
Interfaces.Fortran.Real.  If "some Ada programmers" prefer
Standard.Integer and Standard.Float against the ARM, then they are
wrong.  Nowhere does the ARM state what Standard.Integer or
Standard.Float correspond to in C, COBOL or Fortran.

--
Ludovic Brenta.



  reply	other threads:[~2009-07-06  0:05 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
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 [this message]
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