comp.lang.ada
 help / color / mirror / Atom feed
* unchecked conversion
@ 1991-12-30 23:25 Greg Lomow
  0 siblings, 0 replies; 14+ messages in thread
From: Greg Lomow @ 1991-12-30 23:25 UTC (permalink / raw)


Salu,

I've got a problem that seems easiest to solve by using Ada's
generic procedures for performing unchecked conversion.  I'm
wondering how developers on the net feel about using unchecked
conversion.  Do you think it's a hack or a useful feature? Do you
use it frequently? rarely? never?  Any other useful comments
would be appreciated.

I'll summarize and post any comments mailed directly to me.
-- 
Dr. Greg Lomow
  Director of Product Management
  Jade Simulations

^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: unchecked conversion
@ 1991-12-31 13:53 Jean-Pierre Rosen
  0 siblings, 0 replies; 14+ messages in thread
From: Jean-Pierre Rosen @ 1991-12-31 13:53 UTC (permalink / 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.

^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: unchecked conversion
@ 1992-01-02  6:09 Robert I. Eachus
  0 siblings, 0 replies; 14+ messages in thread
From: Robert I. Eachus @ 1992-01-02  6:09 UTC (permalink / raw)


In article <1546@cyclope.enst.fr> rosen@cyclope.enst.fr (Jean-Pierre Rosen) wri
tes:

   [lots of good stuff deleted]
   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.

   While I am not sure that the authority to permit use of
UNCHECKED_CONVERSION should rest with QA, instead of the chief
architect or a design committee, there should be one hard and fast
rule:  Use of UNCHECKED_CONVERSION in a library package specification
is unchecked perversion.

   Seriously the only way I have seen programmers get into trouble
with UNCHECKED_CONVERSION is to instantiate it in a library package.
When there is a later need to change the implementation of the type,
it turns out that other code depends on the mapping.  Of course there
is now no checking either at compile time or run-time to find out
where these dependancies are.  Might as well program in C.


--

					Robert I. Eachus

"We woke up this morning in the Union of Sovereign States."  Russian
television announcer Alexander Gurnov told viewers Sunday (December 8,
1991).  "We are now in a Commonwealth of Independent States.  You
never know what country we will wake up in tomorrow."

^ permalink raw reply	[flat|nested] 14+ messages in thread
* Unchecked_Conversion
@ 2001-06-07  7:46 Lele
  2001-06-07 13:01 ` Unchecked_Conversion Marc A. Criley
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Lele @ 2001-06-07  7:46 UTC (permalink / raw)


Hi!
I'm a misterious reader...just because I've read for a month this NG without
take part.
I'm a beginner ADA programmer (what a wonderful language!) and I've a
problem...

I should convert data types and record data types from one type to another,
since now I've
used the address attribute to point the same memory space and so accede to
from one type
to another. Ada provides features for bypassing certain language
restrictions and these
features are unchecked; it is the programmer's responsibility to make sure
that they do
not violate the assumptions of the rest of the program. Are there particular
risks about using Unchecked_Conversion? Is it a better approach  the address
attribute?

Thanks!





^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2001-06-11 14:21 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1991-12-30 23:25 unchecked conversion Greg Lomow
  -- strict thread matches above, loose matches on Subject: below --
1991-12-31 13:53 Jean-Pierre Rosen
1992-01-02  6:09 Robert I. Eachus
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

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