From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_20,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7532bb41d4ac458d X-Google-Attributes: gid103376,public From: "Matthew Heaney" Subject: Re: Questions about Unchecked_Conversion Date: 1999/12/15 Message-ID: <38581422_2@news1.prserv.net>#1/1 X-Deja-AN: 561143449 Content-transfer-encoding: 7bit References: <19991215201559.23735.qmail@web218.mail.yahoo.com> Content-Type: text/plain; charset="US-ASCII" X-Complaints-To: abuse@prserv.net X-Trace: 15 Dec 1999 22:20:18 GMT, 129.37.62.206 Organization: Global Network Services - Remote Access Mail & News Services Mime-version: 1.0 Newsgroups: comp.lang.ada Date: 1999-12-15T00:00:00+00:00 List-Id: In article <19991215201559.23735.qmail@web218.mail.yahoo.com> , MaryAnn Atkinson wrote: > 1. Could someone please explain a few things about Unchecked Conversion > and what it really does for me? What if I dont have it there? Ada is a strongly-typed language, which basically means you can't mix apples and oranges. Unchecked_Conversion is the mechanism the language provides for bypassing the type system, in effect allowing you to convert an apple into an orange. > 2. What is the difference (as far as unchecked_conversion is concerned) > > between the following? > > a. FUNCTION ABC(A, B); > b. FUNCTION KLM IS NEW Unchecked_Conversion(A, B); What does function ABC do? Without knowing that, it's impossible to make a comparison. In any case, the profile doesn't match anyway. UC is a generic function that takes a single argument (and returns a single value): function To_B_Type is new Unchecked_Conversion (Source => A_Type, Target => B_Type); B : constant B_Type := To_B_Type (A); > Could the KLM function be defined the same as the ABC function above, but in > the body of the KLM function be placed a WITH Unchecked_Conversion; statement? > Would this have the same effect? I'm not sure what you're asking here. If you mean can you implement a function using UC, the answer is yes: package P is function To_B_Type (A : A_Type) return B_Type; end; with Unchecked_Conversion; package body P is function UC_To_B_Type is new Unchecked_Conversion (A_Type, B_Type); function To_B_Type (A : A_Type) return B_Type renames UC_To_B_Type; end; > 3. What happens if we place the statement With Unchecked_Conversion; > somewhere in the top of our program? Nothing, unless you instantiate the generic, and then call the instantiation during an execution of your program. > Does this mean that from then on, and for the whole pgm, no conversion > exception is raised anywhere? No. If you're trying to suppress exceptions, there are other mechanisms for doing that. -- Yeah, well, no one was present when the dinosaurs lived, so I guess their presence in the fossil record is "only a theory." No one was present when the Grand Canyon was formed either, or the creation of the solar system, or, or, or. Of course evolution is "only a theory." What else would it be as a scientific concept? Skeptic magazine publisher Micheal Shermer, commenting on the recent decision by the Oklahoma board of education to include a disclaimer on school science textbooks warning that evolution is "only a theory." Skeptic web page: http://www.skeptic.com/