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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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-15 12:35:27 PST Path: archiver1.google.com!news1.google.com!news2.google.com!news.maxwell.syr.edu!fu-berlin.de!uni-berlin.de!adsl-213-200-246-247.cybernet.CH!not-for-mail From: Vinzent 'Gadget' Hoefler Newsgroups: comp.lang.ada Subject: Re: += in ada Date: Wed, 15 Oct 2003 21:34:18 +0200 Organization: JeLlyFish software Message-ID: References: <49cbf610.0310101231.2358762a@posting.google.com> <1066224357.499523@master.nyc.kbcfp.com> <1066231159.711433@master.nyc.kbcfp.com> <1066244017.39486@master.nyc.kbcfp.com> Reply-To: v.hoefler@acm.org NNTP-Posting-Host: adsl-213-200-246-247.cybernet.ch (213.200.246.247) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de 1066246524 24890056 213.200.246.247 (16 [175126]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:915 Date: 2003-10-15T21:34:18+02:00 List-Id: Hyman Rosen wrote: >Vinzent 'Gadget' Hoefler wrote: >> You heard about "abstraction"? Ada is a high level *language*, not a >> high level assembler. > >But the concept of "add this to that" *is* an abstraction. Yes, of course. But because it changes its argument (and thus the "state of the system") it should look like a procedure, not like a function. >> The idea was to let the programmer say what it wants and let the >> compiler figure out how to map that onto the target hardware > >Exactly. And what the programmer wants is to add a value to >a variable. And the programmer is allowed to say so. >If I'm keeping a running total, I want to say >"add this item to the total" So why don't you want to say so? >not "compute the sum of the >current total and this item, and replace the current total >with the new total". That's exactly what how a mathematician would express it. Have you ever seen recursive formulas (I suppose so)? They usually look like "a_n =3D a_n+1 + b" and seen that way, the Ada abstraction is *much* more like this. >That's why COBOL had "ADD A TO B." And that's why you abstract exactly this with "Add (A, To =3D> B);" in Ada and not with "B PLUS IS EQUAL TO A". :-P Perhaps another argument, given the notation for overloading predefined operators |function "+" (Left : Type_1; Right : Type_2) return Type_1; I suppose we had to add the notation for these infix-notated-procedures, too: |procedure "+=3D" (Left : in out Type_1; Right : in Type_2); Doesn't look right to me. But wait, let's go further. Suppose we would then suddenly want to write a specification like this: |procedure "+=3D" (Left : in Type_2; Right : in out Type_1); an expression "a +=3D b;" actually would probably be implemented as adding a to _b_, not the other way around like everyone (who has a minimal knowledge of C-like languages) would expect. And we *will* be pretty much confused. Now suppose a language rule that such (specially restricted) procedures suddenly are only allowed to change their first argument would be a little bit, well... strange, simply not logical, confusing, ...? Vinzent.