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,38fc011071df5a27 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-05-30 05:55:29 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!ra.nrl.navy.mil!dca1-feed2.news.algx.net!allegiance!news-out.visi.com!petbe.visi.com!uunet!ash.uu.net!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Ideas for Ada 200X Date: 30 May 2003 08:55:27 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <6a90b886.0305262344.1d558079@posting.google.com> <3ED41344.7090105@spam.com> <3ED46D81.FF62C34F@0.0> <3ED46E07.4340CABC@0.0> <3ED4F3FD.A0EF7079@alfred-hilscher.de> <3ED4ECFC.5060000@cogeco.ca> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1054299327 31495 199.172.62.241 (30 May 2003 12:55:27 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Fri, 30 May 2003 12:55:27 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: archiver1.google.com comp.lang.ada:38086 Date: 2003-05-30T08:55:27-04:00 List-Id: "Mark A. Biggar" writes: > Robert A Duff wrote: > > Wesley Groleau writes: > > > >>>Well, I like the idea of an increment operation, and my reasoning has > >>>nothing to do with typing. The problem is code duplication: you have to > >>>write "I" twice in "I := I + 1;". No big deal if it's just "I", but it > >>>could be a complicated name, so the reader has to careful compare the > >>>text, and also worry about whether the name has side effects. > >> > >>What kind of entity is able to have side-effects AND to be incremented? > > I'm thinking of something like: > > Some_Array[Get_Next_Position] := Some_Array[Get_Next_Position] + 1; > > where Get_Next_Position is a function that increments the current > > position and returns it. You can say "so don't do that", but it's > > allowed in Ada, and when I read the code, I have to think about whether > > this sort of thing is going on. > > Even that case isn't too bad, but if you have a really long expression > you can always use (using your example): > > declare > x: same_as_Some_Array_element_type > renames Some_Array[Get_Next_Position]; > begin > x := x + 1; > end; > > This of course doesn't work if your expression has side-effects or > contains the exaluation of a non-pure function (like your example). > But note that even the += assignment operator in C++ doesn't work > correctly in that case either. Correctly? I guess it depends on what you want it to do. My example: Some_Array[Get_Next_Position] := Some_Array[Get_Next_Position] + 1; is highly unlikely to be correct, since it evaluates Get_Next_Position twice (which is probably not what you want) and it does it in either order (which is almost certainly not what you want). More likely, it's just a mistake, and the programmer wanted the semantics provided by your renaming above (or, more concisely and readably, C's += operator). - Bob