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.1 required=5.0 tests=AXB_XMAILER_MIMEOLE_OL_024C2, BAYES_00,MAILING_LIST_MULTI,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,89814ab9e757697a X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-05-19 14:00:04 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!fr.usenet-edu.net!usenet-edu.net!enst!enst.fr!not-for-mail From: "David C. Hoos, Sr." Newsgroups: comp.lang.ada Subject: Re: user-defined type conversion Date: Sun, 19 May 2002 15:58:50 -0500 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: References: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 1021842003 52127 137.194.161.2 (19 May 2002 21:00:03 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Sun, 19 May 2002 21:00:03 +0000 (UTC) Return-Path: X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.8 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Original-Cc: 18k11tm001@sneakemail.com Xref: archiver1.google.com comp.lang.ada:24384 Date: 2002-05-19T15:58:50-05:00 ----- Original Message ----- From: "Russ" <18k11tm001@sneakemail.com> Newsgroups: comp.lang.ada To: Sent: May 19, 2002 1:29 PM Subject: Re: user-defined type conversion > Type conversion IS a function! It seems to me that I should be able to > do it the same way it is done for the built-in types (float, integer, > etc.). C++ allows that nicely. > With all due respect, the word "function" does not appear at all in section 4.6 (Type Conversions) in the LRM, so I'm not sure one can truthfully make the blanket statement "Type conversion IS a function!" Going back to your original code, you had: type inches is new float; type feet is new float; function inches ( arg: feet ) return inches is begin return inches ( 12.0 * float(feet) ); end inches; First, one cannot multiply a type name by a number, so if we assume that you meant to write return inches (12.0 * float(arg)); what we have is an argument of type Standard.Float (the result of the multiplication) as the argument of a type conversion to the type Inches. This type conversion differs from a function in that it will accept any numeric expression (Integer, Float, Fixed, etc.) whereas a function requires an argument of the specific type with which it was declared. Thus, the conversion of arg to float is ineffectual in an expression used as the argument of a type conversion to Inches, since any numeric expression will do. Since this is the case, overloading will not work, because an argument of type feet is _required_ for the function Inches, and is _legal_ for the type conversion Inches, hence overloading would be ambiguous. I hope I have clarified the matter -- i.e. why a type conversion is _not_ a function -- because its argument type is not fixed.