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 autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f5b0e4b29b2f0c99 X-Google-Attributes: gid103376,public From: Robert Dewar Subject: Re: Who is right? Gnat or http://www.adahome.com/articles/1998-02/ar_lessons95.html? Date: 1999/04/07 Message-ID: <7egnbg$u7b$1@nnrp1.dejanews.com>#1/1 X-Deja-AN: 463793316 References: <01be80c2$114e0890$c24d3a8b@m04w0588> X-Http-Proxy: 1.0 x14.dejanews.com:80 (Squid/1.1.22) for client 205.232.38.14 Organization: Deja News - The Leader in Internet Discussion X-Article-Creation-Date: Wed Apr 07 22:48:19 1999 GMT Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.04 [en] (OS/2; I) Date: 1999-04-07T00:00:00+00:00 List-Id: In article <01be80c2$114e0890$c24d3a8b@m04w0588>, "Daniel Wengelin" wrote: > The ability to pass subprograms as parameters is one of > the nicest features of Ada 95 (it didn't exist in Ada > 83). But accessibility rules make it useless within a > multi-tasking program. Hmmm! I guess that means that Daniel thinks that procedure pointers in C are also useless in multi-tasking programs! The claim is very misleading. Remember this: the only time that accessibility rules are an issue for procedure parameters is for the case of nested procedures. To eliminate the problem, make the procedures in question global. Global procedures, as opposed to global variables, are never a problem for tasking. Now you can react and say, gosh, that's terrible not being able to use pointers to local procedures in a completely general manner, I can't live with that, the language is useless. But then you are also saying that C, C++ and Java are useless -- yes, I know some of the excessive rhetoric from Ada fans seems to say that at times :-) But seriously, we know that this is not the case! P.S. GNAT contains a significant extension, namely the Unrestricted_Access attribute for procedures, which completely eliminates these accesibility checks for procedures, and gives you the same functionality as GNU C's nested procedures and procedure pointers. This comes at a price: (a) it is significantly non-portable. Some implementors claimed it was impossible to provide this kind of capability with displays, and this is one of the times that the language design bent to the will of implementors. Since some implementations (e.g. Aonix) still use displays you cannot expect all Ada implementations to copy this GNAT attribute. (b) it is unsafe, since you can create dangling pointers, and dangling procedure pointers are a particularly unpleasant beast to have around! Nevertheless it is a powerful facility. For a fairly fundamental use of this facility in practice, see the SPITBOL packages provided by GNAT. Robert Dewar Ada Core Technologies -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own