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,88e7ef9008757431 X-Google-Attributes: gid103376,public From: Robert Dewar Subject: Re: Function Calls by Address Date: 1999/09/05 Message-ID: <7qsrtj$9lp$1@nnrp1.deja.com>#1/1 X-Deja-AN: 521205561 References: <37CADE68.6AF06F5D@escmail.orl.lmco.com> <37CEEFFA.7D73F78D@magic.fr> <7qooh7$hbh$1@nnrp1.deja.com> <37CFFEA6.921CBE59@magic.fr> X-Http-Proxy: 1.0 x33.deja.com:80 (Squid/1.1.22) for client 166.72.70.239 Organization: Deja.com - Share what you know. Learn what you don't. X-Article-Creation-Date: Sun Sep 05 04:34:59 1999 GMT X-MyDeja-Info: XMYDJUIDrobert_dewar Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.04 [en] (OS/2; I) Date: 1999-09-05T00:00:00+00:00 List-Id: In article , 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.