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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,8f7d6c5172a1d41b X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!news.belwue.de!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: [Revisited] How to get around "access type must not be outside generic unit" Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <3vwf1b4b2ntl$.l9n17zmh9v8a$.dlg@40tude.net> <1u2mhr9ypij4u.bn3yayn7o9l3$.dlg@40tude.net> <87r6tkocu4.fsf@ludovic-brenta.org> Date: Wed, 24 Jan 2007 14:46:53 +0100 Message-ID: NNTP-Posting-Date: 24 Jan 2007 14:46:54 CET NNTP-Posting-Host: 3ffe0610.newsspool1.arcor-online.net X-Trace: DXC=H?ciDDm_SLS@@RW1FjIB5Sic==]BZ:af^4Fo<]lROoRQ^YC2XCjHcbYZmB@e?7ZOCUDNcfSJ;bb[UFCTGGVUmh?TLK[5LiR>kgRX8UYakB];k\ X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:8481 Date: 2007-01-24T14:46:54+01:00 List-Id: On Wed, 24 Jan 2007 12:58:59 +0100, Ludovic Brenta wrote: > Dmitry A. Kazakov writes: >> Let's take GtkAda as an example. The facts are: >> >> 1. It interfaces GTK+ (C++) > > No, GTK+ is written in C, even though it implements an object-oriented > design. Yes, or at least it has a pure C interface, no classes there. >> 2. It is full of this >> >> package Glib is >> ... >> type Boxed_Copy is access >> function (Boxed : System.Address) return System.Address; >> pragma Convention (C, Boxed_Copy); >> type Boxed_Free is access procedure (Boxed : System.Address); >> pragma Convention (C, Boxed_Free); >> >> function Boxed_Type_Register_Static >> (Name : String; >> Copy : Boxed_Copy; >> Free : Boxed_Free) return GType; >> >> How can I (well, ACT (:-)) apply Convention (C,...) on an anonymous >> access type?! > > These are named access types, AFAICT. Yes, and the first Randy's proposal was to change it to dreadful: function Boxed_Type_Register_Static ( Name : String; Copy : access function (Boxed : System.Address) return System.Address; Free : access procedure (Boxed : System.Address) ); My questions were: 1. How to apply pragma Convention on Copy and Free? 2. Why should this semantically change anything? > GNAT implements access types with convention C as C pointers; Sure. It would be silly to do otherwise. > by contrast, access types with > convention Ada may carry dope information. If you mean that dynamic accessibility checks might help here, then I doubt it. Boxed_Type_Register_Static is called from the body. It is too late to check anything. If a check should fail at run-time that would be even worse than any ugliest stuff, provided that were checked statically. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de