comp.lang.ada
 help / color / mirror / Atom feed
From: Francois Godme <fgodme@magic.fr>
Subject: Re: Function Calls by Address
Date: 1999/09/06
Date: 1999-09-06T00:00:00+00:00	[thread overview]
Message-ID: <37D2F41D.AE1C85F5@magic.fr> (raw)
In-Reply-To: 7qsrtj$9lp$1@nnrp1.deja.com

Robert Dewar wrote:

> In article <ar3rq7.7qb.ln@ds9.klebsch.de>,
>   mario@klebsch.de (Mario Klebsch) wrote:
> > ANd there are a lot of nice things, you only can to that
> elegant with
> > nested procedures. Nested procedures have full access to all
> local
> > variables of the enclosing procedures. If you want to do it in
> C, you
> > have to use static variables and will loose reentrancy.
>
> Right Mario, this is a VERY important point. It is often
> the reason for C library routines being non-thread safe.
> Unfortunately the fix in these C library routines is
> often to add locks to protect these unnecessary global
> variables.
>
> As an example, suppose you are writing printf. Well you
> certainly do not want to write this as one giant function,
> so you write it as multiple functions. Now you *should*
> pass around all global variables, such as the buffer into
> which characters are being written, but it is awfully tempting
> to make this a global variable, with the result that you lose
> thread safety. In Ada, you would write printf with nested
> subprograms that accessed the buffer pointer as a non-local
> uplevel reference (but the variable would be local to printf
> itself).
>
> With regard to name space pollution, it is more than just this.
> The point is that if you see a nested procedure, you know
> immediately that you only have to understand it in the context
> of its enclosing procedure, and indeed if you can ignore this
> code in the reading you are doing right now, you can immediately
> and easily ignore all the nested procedures, knowing that you
> have not missed anything.
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.

There are two kinds of nested procedures: the ones which do not make
uplevel references and the others which do. You gain possible reuses by
unnesting the former. You gain clarity by rewritting the latter to avoid
the uplevel references. All the hidden parameters as well as their
passing modes are then shown. What was previously written has a function
is now correctly expressed as a procedure if for example one uplevel
reference was modified.






  reply	other threads:[~1999-09-06  0:00 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-08-30  0:00 Function Calls by Address Craig Jameson
1999-08-30  0:00 ` Marin David Condic
1999-08-30  0:00   ` Robert Dewar
1999-08-30  0:00   ` Marin David Condic
1999-08-30  0:00     ` Larry Kilgallen
1999-08-30  0:00 ` Robert Dewar
1999-08-30  0:00 ` Robert Dewar
1999-08-31  0:00   ` Martin Gangkofer
1999-08-31  0:00 ` Matthew Heaney
1999-08-31  0:00 ` David Kristola
1999-09-01  0:00 ` Simon Wright
1999-09-02  0:00 ` Francois Godme
1999-09-03  0:00   ` Robert Dewar
1999-09-03  0:00     ` Francois Godme
1999-09-03  0:00       ` David C. Hoos, Sr.
1999-09-04  0:00         ` Robert Dewar
1999-09-05  0:00           ` Francois Godme
1999-09-06  0:00             ` Robert Dewar
1999-09-06  0:00               ` Francois Godme
1999-09-06  0:00                 ` Robert Dewar
1999-09-06  0:00                   ` Bob Collins
1999-09-07  0:00                     ` Pascal Obry
1999-09-06  0:00                 ` Robert Dewar
1999-09-07  0:00                 ` Pascal Obry
1999-09-07  0:00                   ` Francois Godme
1999-09-08  0:00                   ` Francois Godme
1999-09-03  0:00       ` Marin David Condic
1999-09-14  0:00         ` Robert I. Eachus
     [not found]           ` <wcc3dwgb7ii.fsf@world.std.com>
     [not found]             ` <37E81079.CC2566D9@mitre.org>
1999-09-22  0:00               ` Robert A Duff
1999-09-22  0:00                 ` Robert I. Eachus
1999-09-23  0:00                 ` Robert Dewar
1999-09-23  0:00                   ` Robert A Duff
1999-09-03  0:00       ` Robert Dewar
1999-09-03  0:00         ` Ted Dennison
1999-09-04  0:00           ` Jean-Pierre Rosen
1999-09-05  0:00             ` Matthew Heaney
1999-09-05  0:00             ` Ehud Lamm
1999-09-04  0:00         ` Brian Rogoff
1999-09-05  0:00           ` Robert Dewar
1999-09-05  0:00           ` Robert Dewar
1999-09-05  0:00           ` Robert Dewar
1999-09-03  0:00       ` Simon Wright
1999-09-04  0:00       ` Mario Klebsch
1999-09-05  0:00         ` Robert Dewar
1999-09-06  0:00           ` Francois Godme [this message]
1999-09-05  0:00             ` Brian Rogoff
1999-09-06  0:00             ` Robert Dewar
1999-09-08  0:00               ` Georg Bauhaus
1999-09-05  0:00       ` Geoff Bull
1999-09-07  0:00       ` Michael F. Yoder
replies disabled

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