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: 1108a1,2c6139ce13be9980 X-Google-Attributes: gid1108a1,public X-Google-Thread: 103376,3d3f20d31be1c33a X-Google-Attributes: gid103376,public X-Google-Thread: f43e6,2c6139ce13be9980 X-Google-Attributes: gidf43e6,public X-Google-Thread: fac41,2c6139ce13be9980 X-Google-Attributes: gidfac41,public From: Nick Leaton Subject: Re: Interface/Implementation (was Re: Design by Contract) Date: 1997/09/10 Message-ID: <3416EC4B.636B7DA3@calfp.co.uk> X-Deja-AN: 271370040 X-NNTP-Posting-Host: calfp.demon.co.uk [158.152.70.168] References: <340C85CE.6F42@link.com> Reply-To: nickle@pauillac Newsgroups: comp.object,comp.software-eng,comp.lang.ada,comp.lang.eiffel Date: 1997-09-10T00:00:00+00:00 List-Id: Robert Dewar wrote: > > Patrick Doyle says > > < below saves only 1/2 the work. Not an order of magnitude, by any > means. Perhaps you'll argue that 1/2 is important enough? Well,>> > > Not at all, since we can't keep a whole big object in our heads, if we > have to scan ahead to find information, we may easily have to do an > exponential amount of scanning. On the way forward in a linear pass, > we catalog and abstract and remember what needs to be remembered. When > we scan forward, we are looking for a particular piece of information, > and in general we don't know enough to catalog and abstract, even if > we could keep this kind of non-linear scanning straight. > > Consider, in an Algol-68 program you see: > > int q = a * b; > > Contrast this to the Ada statement (Pascal, C, ... would be the same) > > Q : constant Integer := A * B; > > Now in the Ada case, you know you have seen A and B already, and hopefully > the (more descriptive) names that are present will trigger the reference to > your abstracted catalog gained by reading the text prior to this point and > you will remember what you are looking for. If not, a simple search in > reverse order from the point of reading will find the reference for you. > But in Algol-68, you have to do a rather careful scan forward, paying careful > attention to scope marks, to see if there are declarations of A and B in > the same scope and this is a forward reference. You have to do this even > if A and B are already declared, because normal block structure rules > say that you get the innermost one. If you abstract out what you are trying to achieve. > Q : constant Integer := A * B; If I see this statement, I would like to see/goto the declaration of A and B. In Ada, there is the advantage of knowing that one looks higher in the text file. In Algol-68, we have the problems of working out the scope. In both cases the problem is the same, show me the declaration of A or B. Now we can order the text, as in Ada (and enforce it) The disadvantage of this is that I may want, for valid reasons to order things in a different way. Public at the top, private implementation at the bottom. Modifiers next to their attributes. Attributes grouped, modifiers grouped. Procedures grouped. There are different ways that one may want to cluster things. Correct me if I'm wrong but doesn't Ada have some guidelines on how to cluster things? Now if you have the ability to click on A and either go to the declaration, or have another window pop up with the declaration of A in a hypertext way then you can do either, and don't have to scan. > It is this kind of forward reference that the Ada design strenuously tries > to avoid, since it greatly complicates the reading of a program. Worse, > since people generally write linearly anyway, you get in the habit of > reading linearly. When you see in an Algol-68 program > > int A; > ... > begin > int B := A * 2; > ... > > You will almost always just assume that the A is a backward reference to > the declaration that preceded this. In the rare case where in fact there > is another A ahead of you, you will risk making a significant mistake in > understanding. > > Linear comprehension is a very important capability. All text books have > indexes, which are of course functionally similar to hypretext links, but > we do not say "never mind about presenting things in a logical order, > building on what you have already presented, if you reference something > ahead, people can just look it up in the index". Instead we expend a lot > of effort to present things in a linear order (and indeed software for > computing partial orderings of topics to create appropriate linear orderings > is a standard part of the toolset for educators). Again, we have source, we want to see the index. We should have software produce the index. As an alternative to the bottom up construction of Ada, why not enforce an alphabetical ordering. You then know where to scan, albeit it wouldn't read so well as a novel. Is source code a novel, to be read linearly? Or is source code a more collection pictures, where composition and layout, by clustering of components important. And each picture presents a different prespective of the code, either structural, dependency (Ada style), alphabetical, type of feature ... > I notice these days that people often create Hypertext documents that > blatantly disregad this principle, and they are a huge pain to read. Sure > this kind of organization is OK for reference or help material, but it is > NOT the way to present a coherent body of knowledge that you expect people > to acquire in a comprehensive manner. A lot of people complain that they > get totally lost zooming around following links in a Hypertext document, > and vey often they are actually not complaining about the paradigm at all, > but rather its misuse to try to patch up poor document organization. -- Nick Eiffel - Possibly the best language in the world - unless proven otherwise.