comp.lang.ada
 help / color / mirror / Atom feed
From: Robert Dewar <robert_dewar@my-deja.com>
Subject: Re: Inheritance and Polymorphism in Ada !!
Date: 1999/10/24
Date: 1999-10-24T00:00:00+00:00	[thread overview]
Message-ID: <7uuvth$9n2$1@nnrp1.deja.com> (raw)
In-Reply-To: 7uqvb1$2m4$1@nntp3.atl.mindspring.net

In article <7uqvb1$2m4$1@nntp3.atl.mindspring.net>,
  Richard D Riehle <laoXhai@ix.netcom.com> 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.




  reply	other threads:[~1999-10-24  0:00 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-10-15  0:00 Inheritance and Polymorphism in Ada !! Chango Cho
1999-10-15  0:00 ` Lutz Donnerhacke
1999-10-15  0:00 ` Ted Dennison
1999-10-15  0:00 ` Andreas Winckler
1999-10-15  0:00   ` Richard D Riehle
1999-10-15  0:00     ` Matthew Heaney
1999-10-15  0:00       ` Richard D Riehle
1999-10-18  0:00       ` Robert Dewar
1999-10-23  0:00         ` Richard D Riehle
1999-10-24  0:00           ` Robert Dewar [this message]
1999-10-24  0:00             ` Brian Rogoff
1999-10-26  0:00               ` Robert Dewar
1999-10-25  0:00             ` Robert A Duff
1999-10-26  0:00               ` Robert Dewar
1999-10-26  0:00                 ` Robert A Duff
1999-10-18  0:00       ` Robert A Duff
1999-10-19  0:00         ` Robert Dewar
1999-10-20  0:00           ` Robert A Duff
1999-10-21  0:00             ` Robert Dewar
1999-10-21  0:00             ` Simon Wright
1999-10-21  0:00               ` Robert A Duff
1999-10-21  0:00             ` Paul Duquennoy
1999-10-22  0:00         ` Matthew Heaney
1999-10-15  0:00   ` Stephane Barbey
1999-10-15  0:00   ` tmoran
1999-10-15  0:00     ` tmoran
1999-10-15  0:00   ` Matthew Heaney
1999-10-18  0:00     ` Robert A Duff
1999-10-18  0:00       ` Brian Rogoff
1999-10-15  0:00   ` Lutz Donnerhacke
1999-10-18  0:00   ` Robert A Duff
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox