comp.lang.ada
 help / color / mirror / Atom feed
From: Brian Rogoff <bpr@shell5.ba.best.com>
Subject: Re: Self-referential types
Date: 1999/10/18
Date: 1999-10-18T00:00:00+00:00	[thread overview]
Message-ID: <Pine.BSF.4.10.9910181837270.26957-100000@shell5.ba.best.com> (raw)
In-Reply-To: 7udsq9$lv7$1@nnrp1.deja.com

On Mon, 18 Oct 1999, Robert Dewar wrote:
> In article <38077EB3.E6911567@mitre.org>,
>   "Robert I. Eachus" <eachus@mitre.org> wrote:
> >    AFIAK, it is almost always poor engineering to declare
> procedures
> > within other procedures in Ada. The chief exception is
> recursive descent
> > parsers.
> 
> What an *amazing* statement. I am completely flabbergasted!
> 
> First, I don't see recursive descent parsers as being
> relevant here, and see no reason for nesting there.

The argument I hear is that by nesting the inner parsing routines have 
no arguments, FWIW. 

Also, when writing backtracking recursive descent parsers (OK, I've only
done it once in Ada :-) the solution with procedure nesting and procedure 
parameters (faked with generics in Ada) seems fairly understandable to me. 

> There are however MANY MANY examples where nesting makes
> excellent sense, and IMO any language that does not permit
> nested procedures is badly broken,

I agree, but IMO the readability argument, perhaps subsuming your 
arguments, is important enough that all other considerations are
secondary. I find this true even in "sequential" Ada.

-- Brian

> 
> There are zillions of reasons for nesting, but let me just
> give two.
> 
> 1. Localization of names. If you have a small procedure that
> is just called a couple of times within a single procedure,
> it is FAR better to restrict its name space by nesting it
> within the calling procedure, and it is indeed very bad
> style to unnest it in this case. One particular case is
> where you have a recursive implementation of a non recursive
> procedure interface for the client, often referencing one
> of the parameters of the outer procedure non-locally.
 > 
> 2. Nested procedures makes it FAR easier to make things thread
> safe, because you can have variables that are "global" to a set
> of cooperating procedures, but are still on a local
> thread-specific stack of the enclosing procedurers.
> In a language without nested procedures, you often see real
> global variables used for this purpose, which is a common
> source of non-thread safeness. Yes, you can take the position
> that you should never have any non-local references, but this
> often obfuscates the code and is error prone.
> 
> 
> Sent via Deja.com http://www.deja.com/
> Before you buy.
> 
> 





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

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <7ttb4a$8mq$1@nnrp1.deja.com>
     [not found] ` <3802597B.9205AEE8@averstar.com>
1999-10-12  0:00   ` Self-referential types Ted Dennison
1999-10-12  0:00     ` Matthew Heaney
1999-10-13  0:00       ` Ted Dennison
1999-10-12  0:00 ` Robert A Duff
1999-10-12  0:00 ` Vladimir Olensky
1999-10-12  0:00   ` Matthew Heaney
1999-10-12  0:00     ` Ted Dennison
1999-10-12  0:00       ` Matthew Heaney
1999-10-12  0:00     ` Robert I. Eachus
1999-10-12  0:00       ` Matthew Heaney
1999-10-13  0:00         ` Robert I. Eachus
1999-10-13  0:00           ` Brian Rogoff
1999-10-15  0:00             ` Robert I. Eachus
1999-10-15  0:00               ` Marin David Condic
1999-10-15  0:00                 ` Robert I. Eachus
1999-10-18  0:00                   ` Robert Dewar
1999-10-19  0:00                     ` Robert I. Eachus
1999-10-18  0:00               ` Robert Dewar
1999-10-18  0:00                 ` Ed Falis
1999-10-19  0:00                   ` Robert Dewar
1999-10-18  0:00                 ` Brian Rogoff [this message]
     [not found]               ` <7u86su$o5v$1@nntp8.atl.mindspring.net>
1999-10-18  0:00                 ` Robert I. Eachus
1999-10-22  0:00                   ` Richard D Riehle
1999-10-22  0:00                     ` Robert I. Eachus
     [not found]               ` <slrn80fl9f.68j.aidan@skinner.demon.co.uk>
1999-10-19  0:00                 ` Wes Groleau
1999-10-21  0:00                   ` Robert Dewar
1999-10-21  0:00                     ` Jean-Pierre Rosen
1999-10-21  0:00                       ` Robert Dewar
1999-10-21  0:00                     ` Comments (was: Self-referential types) Wes Groleau
1999-10-21  0:00                       ` Ehud Lamm
1999-10-22  0:00                         ` Ted Dennison
1999-10-23  0:00                           ` Ehud Lamm
1999-10-23  0:00                         ` Robert Dewar
1999-10-23  0:00                           ` Ehud Lamm
1999-10-23  0:00                             ` Comments Georg Bauhaus
1999-10-24  0:00                               ` Comments Ehud Lamm
1999-10-26  0:00                                 ` Comments Robert I. Eachus
1999-10-28  0:00                                   ` Comments Jerry van Dijk
1999-10-28  0:00                                     ` Comments Ted Dennison
1999-10-25  0:00                             ` Comments (was: Self-referential types) Wes Groleau
1999-10-23  0:00                       ` M.
     [not found]                       ` <Pine.A41.3.96-heb-2.07.991021191504.30582K-100000@pluto.mscc.huji. <381477c9.e1388ff3@ftw.rsc.raytheon.com>
1999-10-25  0:00                         ` Larry Kilgallen
1999-10-21  0:00                     ` Self-referential types Larry Kilgallen
1999-10-22  0:00                     ` Richard D Riehle
1999-10-23  0:00                       ` Robert A Duff
1999-10-23  0:00                         ` Richard D Riehle
1999-10-24  0:00                       ` Michel DELARCHE
1999-10-13  0:00         ` Vladimir Olensky
1999-10-13  0:00           ` Vladimir Olensky
1999-10-18  0:00           ` Robert Dewar
1999-10-18  0:00             ` Laurent Guerby
1999-10-18  0:00             ` Vladimir Olensky
1999-10-13  0:00         ` Ted Dennison
1999-10-13  0:00           ` Matthew Heaney
1999-10-12  0:00     ` news.oxy.com
1999-10-12  0:00       ` Ted Dennison
1999-10-12  0:00         ` Stanley R. Allen
1999-10-13  0:00           ` Ted Dennison
1999-10-13  0:00         ` Vladimir Olensky
1999-10-14  0:00         ` Multiple Inheritance in Ada 95 [was Re: Self-referential types] Tucker Taft
1999-10-12  0:00       ` Self-referential types Matthew Heaney
1999-10-12  0:00     ` Richard D Riehle
replies disabled

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