comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@gnat.com (Robert Dewar)
Subject: Re: Refactoring and Ada
Date: 23 Feb 2002 14:55:29 -0800
Date: 2002-02-23T22:55:29+00:00	[thread overview]
Message-ID: <5ee5b646.0202231455.317a444a@posting.google.com> (raw)
In-Reply-To: 3C7324BF.996E182B@adaworks.com

Richard Riehle <richard@adaworks.com> wrote in message news:<3C7324BF.996E182B@adaworks.com>...
> Larry Kilgallen wrote:
> 
> > > What happens when you read junk off the interface?
> >
> > Doesn't 'Valid detect that ?
> 
> It turns out that 'Valid is not as useful as many of us 
> thought it was. Fo example,  the result of an erroneous 
> result from unchecked conversion

What do you mean  by "an erroneous result" from unchecked conversion.
The word erroneous does not appear in RM section 13.9.

Now it is true that UC is implementation defined, and one
can imagine an unusable implementation that "defines" the
action of some UC's to be the equivalent of erroneous, but
if you find such a compiler I suggest you file it in the
circular file, since it is working hard to be useless.

> which we originally 
> thought was harmless if we checked it ourselves
> with 'Valid before using it is a problem.   Consider the 
> following,
> 
>                type X is ... ;
>                type Y is ... ;
> 
>                function Convert is new 
>                  Ada.Unchecked_Conversion
>                    (Source => Y, Target => X);
> 
> 
>                 X := Convert (Y);     -- suppose X is 
>                        erroneous or not valid

First of all, a value can never be erroneous, this is sloppy
terminology. Only a program execution can be
erroneous, and certainly one does NOT expect the above to
be erroneous on any reasonable compiler. A compiler would
have to explicitly document this as erroneous, and it would
be treading on thin ice, since the idea of implementation defined is
to exclude erroneous behavior. Yes a language
lawyer can argue that erroneousity is included in the range of
possible impl defined values, but that's no excuse for
a compiler to malfunction this way. There are many many
ways in which compilers can be made unusable, this is one
of them, and there is no reason to put up with it.


>                 if X'Valid then ...      -- We used to 
>                   think this was OK.

It's just fine

>                                                  -- Some 
> compilers fail on this because of an
> interpretation of the ALRM rules.

There is no interpretation involved here, this is a matter
of implementation defined behavior.

>  At present, one must wonder about the usefulness of 
> 'Valid.


That's like finding a compiler that does all multiplications by
repeated addition and then wondering about the utility of the *
operator in Ada.

On a decent compiler, the above works fine, and is a useful
(and commonly used) use of 'Valid.



  parent reply	other threads:[~2002-02-23 22:55 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-01 15:13 Refactoring and Ada Paul Anderson
2002-02-02 17:48 ` Nick Roberts
2002-02-02 20:36   ` Pat Rogers
2002-02-03  0:21     ` Nick Roberts
2002-02-03 13:53       ` Robert Dewar
2002-02-03 19:23         ` Nick Roberts
2002-02-04  2:17           ` Robert Dewar
2002-02-04 20:48             ` Nick Roberts
2002-02-04 22:31               ` Pat Rogers
2002-02-04 22:43                 ` Marin David Condic
2002-02-06  2:51                 ` Nick Roberts
2002-02-03 18:50       ` Simon Wright
2002-02-04  4:32     ` Richard Riehle
2002-02-04 12:28       ` David C. Hoos, Sr.
2002-02-04 17:03         ` Richard Riehle
2002-02-06 17:19           ` Robert A Duff
2002-02-04 17:59       ` Robert Dewar
2002-02-04 18:50         ` Pascal Obry
2002-02-05  1:07           ` Robert Dewar
2002-02-05  1:44         ` Richard Riehle
2002-02-06 17:42           ` Robert A Duff
2002-02-06 17:32         ` Robert A Duff
2002-02-07  8:45         ` Dr. Michael Paus
2002-02-07 13:54           ` Pat Rogers
2002-02-03 13:48   ` Robert Dewar
2002-02-03 19:38     ` Nick Roberts
2002-02-04  2:20       ` Robert Dewar
2002-02-08 21:21       ` Paul Anderson
2002-02-03  9:45 ` Volkert
2002-02-04  0:06 ` Refactoring and Ada (tool I'd like to have...) David Emery
2002-02-08  9:24 ` Refactoring and Ada Martin Dowie
2002-02-08 15:15   ` Ted Dennison
2002-02-08 15:52     ` Pat Rogers
2002-02-08 16:07       ` OT : " martin.m.dowie
2002-02-08 17:11         ` Pat Rogers
2002-02-09 19:46           ` martin.m.dowie
2002-02-09 23:04             ` Pat Rogers
2002-02-10 13:57               ` Martin Dowie
2002-02-08 16:06     ` martin.m.dowie
2002-02-08 17:07       ` Pat Rogers
2002-02-09 19:48         ` martin.m.dowie
2002-02-09 23:05           ` Pat Rogers
2002-02-10  1:30     ` Marc A. Criley
2002-02-10  2:58       ` tmoran
2002-02-11 15:27       ` Marin David Condic
2002-02-12 19:16         ` Simon Wright
2002-02-15 19:43           ` Marin David Condic
2002-02-15 20:33           ` Matthew Heaney
2002-02-15 21:40             ` Larry Kilgallen
2002-02-19 16:54               ` Matthew Heaney
2002-02-19 19:39                 ` Larry Kilgallen
2002-02-20  4:23                   ` Richard Riehle
2002-02-20  5:20                     ` Mark Biggar
2002-02-20  9:58                     ` Pat Rogers
2002-02-20 17:14                       ` Matthew Heaney
2002-02-20 17:18                         ` Pat Rogers
2002-02-20 18:08                           ` Matthew Heaney
2002-02-20 22:12                             ` Pat Rogers
2002-02-23 22:48                             ` Robert Dewar
2002-02-21  0:41                           ` Randy Brukardt
2002-02-21  1:31                             ` Pat Rogers
2002-02-22 14:37                             ` Pat Rogers
2002-02-22 21:23                               ` Randy Brukardt
2002-02-23 23:04                                 ` Robert Dewar
2002-02-25 20:26                                   ` Randy Brukardt
2002-02-23 23:21                                 ` Robert Dewar
2002-02-23 22:58                             ` Robert Dewar
2002-02-23 22:55                     ` Robert Dewar [this message]
2002-02-26  1:05                       ` Nick Roberts
  -- strict thread matches above, loose matches on Subject: below --
2002-02-05  6:15 Christoph Grein
2002-02-07 11:26 Christoph Grein
2002-02-07 18:31 ` Dr. Michael Paus
2002-02-08 12:45   ` Robert Dewar
2002-02-08 17:20     ` Dr. Michael Paus
2002-02-20  6:19 Christoph Grein
replies disabled

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