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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham 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 23:21:24 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!sn-xit-01!supernews.com!207.217.77.43.MISMATCH!newsfeed1.earthlink.net!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread2.prod.itd.earthlink.net.POSTED!59ce1190!not-for-mail Message-ID: <3CE895D9.5F635D2A@acm.org> From: Jeffrey Carter X-Mailer: Mozilla 4.7 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: user-defined type conversion References: <3CE81644.D3B7CE25@acm.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Mon, 20 May 2002 06:21:24 GMT NNTP-Posting-Host: 63.184.104.132 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 1021875684 63.184.104.132 (Sun, 19 May 2002 23:21:24 PDT) NNTP-Posting-Date: Sun, 19 May 2002 23:21:24 PDT Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: archiver1.google.com comp.lang.ada:24403 Date: 2002-05-20T06:21:24+00:00 List-Id: Russ wrote: > > Yes, I meant "arg" rather than "feet", and I don't think it's an > infinite resursion. The "inches" function takes a "feet" argument, > whereas the call of "inches" within it takes a "float" argument. > That's two different functions. I thought you were trying to write a type conversion to complement or replace the existing type conversion "inches". Type conversions of this sort may have a value of any numeric type as the argument, so clearly your user-defined equivalent must behave the same way, leading to infinite recursion. One cannot consider a numeric type declaration as declaring a number of overloaded functions with the same name as the type and parameters of every other numeric type because one can apply type conversions to numeric types not known at the point of the declaration. > I still don't see why I shouldn't be able to make my own type/unit > conversion that has the same simple syntax as the built-in type > conversions. Until I do, I consider it a minor deficiency of the > language. I don't see why I can't define subprograms in terms of pattern matching. I don't see why I can't define new operators. I don't see why I can't write natural English and have the Ada compiler generate appropriate code. Are these deficiencies of Ada or of my understanding? There are many features that it would be nice for Ada to have. The ability to have user-defined type conversions with the same name as a type is one of them. It's difficult to have a consistent language definition that allows this and all the good things that Ada does allow, so the language designers do not allow it. Of course, you can define a function with the same name as the type in a different declarative region, but you won't be able to refer to both the type and the function in the same scope without a prefix on at least one of them. -- Jeff Carter "If you think you got a nasty taunting this time, you ain't heard nothing yet!" Monty Python and the Holy Grail