comp.lang.ada
 help / color / mirror / Atom feed
From: mcsun!corton!enst!cyclope!rosen@uunet.uu.net  (Jean-Pierre Rosen)
Subject: Re: unchecked conversion
Date: 31 Dec 91 13:53:05 GMT	[thread overview]
Message-ID: <1546@cyclope.enst.fr> (raw)

UNCHECKED_CONVERSION is a FUNDAMENTAL feature of Ada. It is needed each time
you need to look at some data from different abstraction layers. For example,
suppose you are implementing an access method for files. The spec would look
like:
   generic
      type ITEM is private;
   package ACCESS_METHOD is
      ... various access procedures, returning values of type ITEM

However, inside the package body, you would view the underlying OS file as
a blocks of bytes. You need UNCHECKED_CONVERSION to view the same bytes
sometimes as a value of type ITEM, sometimes as a stream of bytes.

Note that UNCHECKED_CONVERSION is *safer* than passing the 'ADDRESS of an objec
t
of type ITEM, since it works on values, not on objects. Descriptors, dope 
vectors etc. that are part of the object (and included in the memory area 
referred to by 'ADDRESS) are not included.

Of course, UNCHECKED_CONVERSION should not be used to get rid of Ada's typing
model. But the way it is designed, any use of it cannot be concealed since
users must "with" it. In a project, QA should forbid using UNCHECKED_CONVERSION
unless a waiver is granted. QA will then just ask the library manager for units
that depend on UNCHECKED_CONVERSION to check that only authorized modules make
use of it, NO CODE INSPECTION is necessary. This is a great improvement over
undisciplined type-cast (like in C/C++) where careful reading of all code
is mandatory.

             reply	other threads:[~1991-12-31 13:53 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1991-12-31 13:53 Jean-Pierre Rosen [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-06-07  7:46 Unchecked_Conversion Lele
2001-06-07 13:01 ` Unchecked_Conversion Marc A. Criley
2001-06-07 13:21 ` Unchecked_Conversion Ted Dennison
2001-06-10 18:20   ` Unchecked_Conversion Robert B. Love 
2001-06-10 19:48     ` Unchecked_Conversion Jeff Creem
2001-06-10 22:10     ` Unchecked_Conversion Keith Thompson
2001-06-11 13:56     ` Unchecked_Conversion Ted Dennison
2001-06-11 14:21     ` Unchecked_Conversion Marin David Condic
2001-06-07 14:01 ` Unchecked_Conversion Jacob Sparre Andersen
2001-06-07 19:44 ` Unchecked_Conversion tmoran
2001-06-09 17:07   ` Unchecked_Conversion Robert A Duff
1992-01-02  6:09 unchecked conversion Robert I. Eachus
1991-12-30 23:25 Greg Lomow
replies disabled

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