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-Thread: 103376,81bb2ce65a3240c3 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.190.104 with SMTP id gp8mr7635828pbc.4.1341139636500; Sun, 01 Jul 2012 03:47:16 -0700 (PDT) Path: l9ni5708pbj.0!nntp.google.com!news2.google.com!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Brian Drummond Newsgroups: comp.lang.ada Subject: Re: What would you like in Ada202X? Date: Sun, 1 Jul 2012 10:47:15 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: <3637793.35.1335340026327.JavaMail.geo-discussion-forums@ynfi5> Mime-Version: 1.0 Injection-Date: Sun, 1 Jul 2012 10:47:15 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="DkTdSjxOCm6DqG+Uf7eArg"; logging-data="7030"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19XGkdw7Z2Q48GLqxM56UunFMSJhJxZKuI=" User-Agent: Pan/0.135 (Tomorrow I'll Wake Up and Scald Myself with Tea; GIT 30dc37b master) Cancel-Lock: sha1:zNe+/j8li/AhIRKn0csfO5Rf5PE= Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Date: 2012-07-01T10:47:15+00:00 List-Id: On Sat, 30 Jun 2012 21:26:09 +0300, Niklas Holsti wrote: > On 12-06-30 20:37 , Brian Drummond wrote: >> On Sat, 30 Jun 2012 11:51:51 -0400, Robert A Duff wrote: >> >>> Brian Drummond writes: >>> >>>> We can overload existing operators (+,-,etc) >>>> But we can't define new ones, e.g. // >> If P1."//" and P2."//" apply to different types, does it really matter >> that they have different precedences, unless the base type is the same? > Overload resolution would be very messed up. The parsed structure of the > expression would be different for different resolutions of overloaded > names and operators. Ugh! I have to agree with that, and Robert's view that it entangles syntax and semantics too closely. So it would require the simplest possible solution to the precedence problem : > IMO the new operators should all be put at the same precedence level, > either above or below all the predefined operators. Perhaps below (most > loosely binding) is the better choice. Or: >The parentheses around the operands could even be > required. I think that is what the "unrelated precedence" (like "and" and "or) achieves, and it is probably the best approach. It also solves Oliver's point regarding mixing unary and binary operators. > New unary operators should also be allowed, of course. Yes, if possible. I didn't mention unary operations because I wasn't clear if that added further issues. >> "Add(A,Multiply(B,C))"... > > I agree that defining new operators could be useful. It could also be > overused to make programs hard to read and understand, for a reader who > does not already know what the new operators mean. Right. A good use would be where the operators are already currency in the problem domain, or otherwise familiar to the readers. There may be uses in translating APL programs (if anyone is still familiar with APL). Another valid use might be to replace e.g. "+" in string manipulation where addition (or positive value) is not the intended meaning, but "+" is just the least objectionable symbol available. A new operator might ease reading by removing confusion with addition. - Brian