Newsgroups: comp.lang.c++,comp.lang.smalltalk,comp.lang.eiffel,comp.lang.ada,comp.object,comp.software-eng
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!oitnews.harvard.edu!purdue!ames!enews.sgi.com!news.mathworks.com!howland.erols.net!newsxfer3.itd.umich.edu!news.bbnplanet.com!su-news-hub1.bbnplanet.com!pacbell.com!amdahl.com!netcomsv!uu4news.netcom.com!telesoft!kst
From: kst@aonix.com (Keith Thompson)
Subject: Re: OO, C++, and something much better!
X-Nntp-Posting-Host: pulsar
Message-ID: <E42qtp.FF2@thomsoft.com>
Originator: kst@pulsar
Lines: 31
Sender: news@thomsoft.com (USENET News Admin @flash)
Organization: Aonix, San Diego, CA, USA
References: <dewar.852851538@merv> <E3xqqp.4uA@syd.csa.com.au> <32DA822A.2FD8@lmtas.lmco.com> <dewar.853194201@merv>
Date: Thu, 16 Jan 1997 00:03:23 GMT
Xref: glinda.oz.cs.cmu.edu comp.lang.c++:240648 comp.lang.smalltalk:49186 comp.lang.eiffel:17378 comp.lang.ada:56032 comp.object:59853 comp.software-eng:52567

In <dewar.853194201@merv> dewar@merv.cs.nyu.edu (Robert Dewar) writes:
> Ken Garlington wrote
> 
> "    type My_Integer is new Integer;
>     function To_Int is new Unchecked_Conversion ( My_Integer, Integer );"
> 
> 
> Why on earth use an unchecked conversion here when a perfectly ordinary,
> and completely safe type conversion will work just fine?

1. I think it was meant to be a simple example of what you can do
   Ada.Unchecked_Conversion, not a useful program.

2. A simple conversion wouldn't work; you can't assign to a conversion
   (unless passing it as an "out" or "in out" parameter is considered
   assignment).

3. Actually, Unchecked_Conversion won't work either; an earlier version
   of GNAT incorrectly allowed assignment to an Unchecked_Conversion.

If you really want a writable view of an object with a type other than the
object's declared type, you can use 'Access and Unchecked_Conversion on
access types, though it's generally simpler to do an Unchecked_Conversion
on the type itself in the opposite direction.  Be careful; it's really
easy to get erroneous execution this way.

-- 
Keith Thompson (The_Other_Keith) kst@aonix.com <http://www.aonix.com> <*>
TeleSo^H^H^H^H^H^H Alsy^H^H^H^H Thomson Softw^H^H^H^H^H^H^H^H^H^H^H^H^H Aonix
10251 Vista Sorrento Parkway, Suite 300, San Diego, CA, USA, 92121-2706
"SPOON!" -- The Tick
