comp.lang.ada
 help / color / mirror / Atom feed
From: Ken Garlington <kennieg@flash.net>
Subject: Re: 'size attribute inheritance
Date: 1997/08/13
Date: 1997-08-13T00:00:00+00:00	[thread overview]
Message-ID: <33F250A4.2B42@flash.net> (raw)
In-Reply-To: mheaney-ya023680001208971859210001@news.ni.net


Matthew Heaney wrote:
> 
> >Matthew says
> >
> ><<YOU SHOULD NEVER USE CONSTRAINED SUBTYPES TO TRANSMIT OR RECIEVE DATA
> >ACROSS AN EXTERNAL INTERFACE.>>
>

[snip]

> My own lesson was learned the hard way on a VAX.  I was reading into an
> object of an enumeration type, and using that object in a case statement.
> I would get ACCVIO (equivalent to a segmentation fault under UNIX) when I
> got a flakey value from the hardware, which could happen at startup, and
> when power was cycled.

Note that this can happen even if your rule is followed. For example,
if you provide an address to the hardware, the device can "flake" and
write the result to a different address. Also, the device may mislead
you as to the number of consecutive storage units it will write.

On the other hand, a constrained subtype is just as useful as a base
type
if it matches the size of the expected storage units to be written (in
Ada or
Ada 83), or if you use 'Valid (Ada only), which is intended for this
case.

> Consider yourself fortunate that you get any indication that a value is
> outside its constrained range.  But even then, if you're flying a plane
> controlled by software that has an illegal value for an object, is a core
> dump really want you'd want to happen?

No; on the other hand, you don't want to either weaken the typing
abilities
of Ada, nor do you want to introduce too many base types. The intent of
your rule can be followed with constrained subtypes, so long as you
understand the nature of your I/O device.

> Please be very, very careful with data from an external source.

As always!

> 
> --------------------------------------------------------------------
> Matthew Heaney
> Software Development Consultant
> <mailto:matthew_heaney@acm.org>
> (818) 985-1271




  parent reply	other threads:[~1997-08-13  0:00 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-08-09  0:00 'size attribute inheritance Carlos Palenzuela
1997-08-10  0:00 ` Matthew Heaney
1997-08-11  0:00   ` Robert Dewar
1997-08-12  0:00     ` Matthew Heaney
1997-08-13  0:00       ` Robert A Duff
1997-08-13  0:00         ` Matthew Heaney
1997-08-14  0:00           ` Robert A Duff
1997-08-14  0:00             ` Dale Stanbrough
1997-08-16  0:00           ` Robert Dewar
1997-08-16  0:00             ` Ken Garlington
1997-08-17  0:00               ` Robert A Duff
1997-08-17  0:00               ` Robert Dewar
1997-08-18  0:00                 ` Robert A Duff
     [not found]                   ` <dewar.872433846@merv>
1997-09-03  0:00                     ` Robert A Duff
1997-09-06  0:00                       ` Robert Dewar
1997-09-08  0:00                         ` Robert A Duff
1997-08-13  0:00       ` Ken Garlington [this message]
1997-08-13  0:00         ` Matthew Heaney
1997-08-10  0:00 ` Robert A Duff
1997-08-10  0:00 ` Robert Dewar
1997-08-11  0:00   ` Ken Garlington
1997-08-11  0:00   ` Matthew Heaney
replies disabled

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