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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,97188312486d4578 X-Google-Attributes: gid103376,public From: mheaney@ni.net (Matthew Heaney) Subject: Re: What's the best language to start with? [was: Re: Should I learn C or Pascal?] Date: 1996/09/28 Message-ID: #1/1 X-Deja-AN: 185950692 references: <51knkn$j61@dub-news-svc-8.compuserve.com> <01bba638$e913f800$87ee6fce@timpent.a-sis.com> <324844D7.1507@trw.com> <52g7f6$1fv0@uni.library.ucla.edu> <324BF0E1.74A7@sandia.gov> <324C2C77.1B72@lmco.com> content-type: text/plain; charset=ISO-8859-1 organization: Estormza Software mime-version: 1.0 newsgroups: comp.lang.ada Date: 1996-09-28T00:00:00+00:00 List-Id: In article <324C2C77.1B72@lmco.com>, george.haddad@lmco.com wrote: > Observation: Ada models the notion of the "successor of i" much more >closely (IMHO) with T'SUCC(i). AFAIK, "the successor of i" does not >imply that i _changes_ as a result. Of course, if you are referring to >i as used in sigma and pi notation (i.e., summations and product >sequences) then one might think of i as "taking on the value of its >successor". You've identified the fact that there are really 2 issues we're debating: the concept of a value and the concept of assignment of a value to an object. The concept of "successor to i" is modeled very elegantly in Ada by T'Succ (i), but people seem to be having a problem with how one assigns that value. The abstract world of mathematics is all very theoretically interesting, but in the end, we still have to program real programs on very concrete computers. So the pure, theoretical model that mathematics gives us is of course the goal, but in this world on this computer I might not reach that goal exactly. So while the statement i := t'succ(i); might make the mathematician happy, it doesn't seem to sit well with many real-world programmers, who would seem to prefer increment (i); This is an area where one may justifiably criticize Ada (and many have), in that it's *too* abstract. For example, I've often seen something on paper that uses pure functions, but when I have to code it, would use procedures, for no other reason than efficiency. Consider a set: S = {1, 2, 3} Now to add an element to S, on paper, I would say S <- S union 4 If I did this exactly in Ada: S : Set; ... S := Union_Of (S, 4); this would be horribly inefficient, because I'd have to make a copy of S, then add 4 to that copy, and assign the whole thing back to S. But the procedure Add (4, To => S); conveys exactly what I want to do, which is to add an element to an already-existing set. So the paper-based solution isn't always directly applicable to what must be done on this computer, it's more a model for what must be done. So when the C programmer says i++; he is saying "increment the object i," which I feel is better than i = i + 1; because it more clearly captures his intent, and in spite of the fact the 2nd method is more pure. matt -------------------------------------------------------------------- Matthew Heaney Software Development Consultant mheaney@ni.net (818) 985-1271