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, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7508aa0d80b8bf66 X-Google-Attributes: gid103376,public From: Robert Dewar Subject: Re: Inheritance and Polymorphism in Ada !! Date: 1999/10/24 Message-ID: <7uuvth$9n2$1@nnrp1.deja.com>#1/1 X-Deja-AN: 539913541 References: <7u64k3$l1d$1@hiline.shinbiro.com> <3806DC34.1513E8B1@frqnet.de> <7u7o36$tv8$1@nntp6.atl.mindspring.net> <38077b65_1@news1.prserv.net> <7udtav$ma4$1@nnrp1.deja.com> <7uqvb1$2m4$1@nntp3.atl.mindspring.net> X-Http-Proxy: 1.0 x32.deja.com:80 (Squid/1.1.22) for client 205.232.38.14 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Sun Oct 24 13:00:33 1999 GMT X-MyDeja-Info: XMYDJUIDrobert_dewar Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.04 [en] (OS/2; I) Date: 1999-10-24T00:00:00+00:00 List-Id: In article <7uqvb1$2m4$1@nntp3.atl.mindspring.net>, Richard D Riehle wrote: > I remembered reading a short discussion of the Algol > equivalent of declare blocks in Dijkstra's oldie but goodie, > A Discipline of Computer Programming. So I pulled my > dog-eared copy from a nearby bookshelf to re-read it. > Read chapter 10 for a well-reasoned criticism of this notion. > > Not very much has changed in the Ada declare block. All the > same problems exist that we had with Algol. It is quite > wonderful that we are still arguing the same issues that we > were arguing about in 1976 when Dijkstra's book was published. Yes, indeed, this is an old argument :-) My feeling is that people do not use declare blocks NEARLY often enough. In a language like C or Ada (unlike say COBOL which has a light syntax for local procedures, sorry, can't help getting in that dig :-) it is impractical to introduce a new procedure every time we have a local variable. For example, if we say t := a; a := b; b := t; to do an exchange, it is usually unhappily heavy to introduce a special local exchange procedure that is used once (even worse, for those who can't bear to nest procedures, or, horrors are not allowed to do so by the language they are using, a global procedure). On the other hand, we far prefer declare t : constant integer := a; begin a := b; b := t; end; because it tells the reader that it is safe to forget the value of t, since it is never referenced again, whereas the original set of three assignments happened to leave t set to a value which could be referenced later (with no indication of whether or not it actually is so referenced). And then of course in Ada, the paradigm: read (N); declare x : matrix (1 .. N, 1 .. N); ... is very valuable. I really think the notion of declare blocks is a very important one. Algol-60 of course had both nested procedures and nested blocks. It is interesting that there have been three threads of development of these ideas: Omit nested procedures, keep nested blocks (C, C++) Omit nested blocks, keep nested procedures (Pascal) Keep both (PL/1, Ada) I far prefer the third approach. Note that the issue of heaviness of syntax (and whether you need a marker between declarations and statements, which is the point Bob Duff has made) is quite orthogonal to the fundamental point that nested blocks are very valuable. RObert Dewar Sent via Deja.com http://www.deja.com/ Before you buy.