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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,54889de51045a215 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-10-24 22:07:03 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: 18k11tm001@sneakemail.com (Russ) Newsgroups: comp.lang.ada Subject: Re: += in ada Date: 24 Oct 2003 22:07:03 -0700 Organization: http://groups.google.com Message-ID: References: <3F92B607.809@comcast.net> <3F937806.9080205@comcast.net> <3F953687.9070406@comcast.net> <3F96DF31.5040501@comcast.net> <3F97E1D8.1020509@comcast.net> NNTP-Posting-Host: 63.194.87.148 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1067058423 4199 127.0.0.1 (25 Oct 2003 05:07:03 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 25 Oct 2003 05:07:03 +0000 (UTC) Xref: archiver1.google.com comp.lang.ada:1647 Date: 2003-10-24T22:07:03-07:00 List-Id: "Robert I. Eachus" wrote in message news:<3F97E1D8.1020509@comcast.net>... > Russ wrote: > > > I still don't understand where you got that impression. For overloaded > > "+=", I don't see how it could be anything other than a procedure. > > All that discussion about how A += 1 is more efficient than A := A + 1; I never said anything about the efficiency of += for scalars. I only mentioned the efficiency advantage for vector and matrix operations. > The procedural version is theoretically significantly less efficient > than A := A + 1; although most compilers will, when asked, do the > inlining that makes it exactly equivalent. If you think that A += 1 is > more efficient you are talking about augmented assignment. (Assignment > with the addition as a side-effect.) As I showed, in Ada if you try to > generalize that to cover all cases, there are insoluble problems. > > > On the other hand, for built-in types such as integer and float (and all > > the scalar types derived from them), I would expect "+=" to be > > automatically available. It would be silly to require the programmer > > to define all those. I hope that is clear too. > > If you check the tread carefully, you will find articles where I and at > least one other ARG member discussed adding Inc as a predefined > operation for Integer types. Several ARG members favor it, others think > it is unnecessary. We could also discuss whether there should be one > procedure with a default parameter: > > procedure Inc (L: in out Integer; R: in Integer := 1); > > or two separate versions. Personally I think the one parameter version > is enough. And I pointed out that "Inc" is fine for incrementing scalars, but "+=" (or ":+") is also good notation for vectors and matrices, as well as other non-scalar types. It kills two birds with one stone.