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.4 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00 autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,73f15dbe4ec16d06 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-06-03 07:59:45 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!out.nntp.be!propagator2-sterling!news-in.nuthinbutnews.com!cyclone1.gnilink.net!spamkiller2.gnilink.net!nwrdny02.gnilink.net.POSTED!53ab2750!not-for-mail From: "Frank J. Lhota" Newsgroups: comp.lang.ada References: <1ec946d1.0306021542.58714996@posting.google.com> Subject: Re: Adding "()" operator to Ada 200X X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Message-ID: Date: Tue, 03 Jun 2003 14:59:44 GMT NNTP-Posting-Host: 151.203.3.229 X-Complaints-To: abuse@verizon.net X-Trace: nwrdny02.gnilink.net 1054652384 151.203.3.229 (Tue, 03 Jun 2003 10:59:44 EDT) NNTP-Posting-Date: Tue, 03 Jun 2003 10:59:44 EDT Xref: archiver1.google.com comp.lang.ada:38492 Date: 2003-06-03T14:59:44+00:00 List-Id: "Matthew Heaney" wrote in message news:1ec946d1.0306021542.58714996@posting.google.com... > But all you've done is change the syntax. None of your suggestions > allow you to do more than is already provided by the library. But isn't the same thing true of all operators? Instead of defining "+" for my types, I could define a function named Sum. It would have the same functionality as the "+", it would just read differently. OTOH, how an expression reads is very important! One of Ada's strengths is its readability, and I would consider D := B * B - 4 * A * C; to be more readable than D := Difference( Product( B, B ), Product( Product( 4, A ), C ) ); Part of why the former expression is clearer is that it uses the standard arithmetic notation that one uses for numeric types. Thus, even if A, B, C and D are not a numberic type (they could be matrices, for example), we understand the author's intentions here. >From the very beginning, Ada has allowed programmers to define operators such as "+", "*", "and", etc. for user defined types, so that the user types can use the same notation as the predefined types. By analogy, why not do the same for a user type that is analgous to an array? Isn't B( I ) := A( P( I ) ) + C( I ); clearer than Replace_Element( B, I, Element( A, Element( P, I ) ) + Element( C, I ) ); > If you're going to make a change in the syntax of the language, then > it has be because it allows you to do something you can't do already. > For example, there's no way to declare an access subtype right now > that means "all the access values except null." A useful language > change would be to allow the declaration: > > type Element_Access_Base is access all Element_Type; > > subtype Element_Access is Element_Access_Base range not null; This is an interesting idea, and we should probably pursue it further in another. Constraint checking has always been tremendously helpful. There is one potential (but not insurmountable) problem with this proposal: in the absence of explicit initializations, an access variable is initialized to null.