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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,243dc2fb696a49cd X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!news.maxwell.syr.edu!border1.nntp.dca.giganews.com!nntp.giganews.com!local1.nntp.dca.giganews.com!nntp.megapath.net!news.megapath.net.POSTED!not-for-mail NNTP-Posting-Date: Fri, 24 Sep 2004 16:00:28 -0500 From: "Randy Brukardt" Newsgroups: comp.lang.ada References: Subject: Re: Ada Popularity: Comparison of Ada/Charles with C++ STL (and Perl) Date: Fri, 24 Sep 2004 16:01:38 -0500 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 Message-ID: <77udnTGdWsdxF8ncRVn-sw@megapath.net> NNTP-Posting-Host: 64.32.209.38 X-Trace: sv3-Pu8Z5jSBZBmbz3FJGxS0fjQSfc/qCzdHTb+H3mcdVHRQ8ifrjmMEo5d8gj3dPbntVRmssk40JdkD1Bj!M8BjwV8Wt84/dcnfLiksNOlOwbBpp52qHqZ6WfIyvEV4LR3LKZNd7Bwyd4MN2ql3nLbciPEC4SmN X-Complaints-To: abuse@megapath.net X-DMCA-Complaints-To: abuse@megapath.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.13 Xref: g2news1.google.com comp.lang.ada:4138 Date: 2004-09-24T16:01:38-05:00 List-Id: "Dale Stanbrough" wrote in message news:MrNoSpam-4FAA69.16322324092004@news-server.bigpond.net.au... > Matthew Heaney wrote: > > > Dale Stanbrough writes: > > > > > Talking about removing restrictions - will Ada 2005 allow for downward > > > closures (I read that the one reason for it's exclusion was a compiler > > > which is no longer with us). > > > > Yes. The only caveat is that the procedure pointer cannot be copied. > > How is this enforced? Via accessibility. The accessibility of an anonymous access-to-subprogram used as a parameter is infinite, so you can put anything into it (of course), but you are not allowed to convert to another type (unless it too is anonymous access-to-subprogram used as a parameter). > > AI-302 depends on this new feature. For example, the passive iterator > > looks like this: > > > > procedure Iterate > > (Container : in CT; > > Process : not null access procedure (Position : in Cursor)); > > > Can you specify a type for the procedure pointer? > e.g. > > type Proc_Ptr is access procedure (Position : in Cursor); > procedure Iterate > (Container : in CT; > Process : not null Proc_Ptr); You can do that, but you get the Ada 95 accessibility rules. That's necessary as access-to-subprogram is often used to interface to C or other foreign code, and thus those types must be implementable as thin pointers (just a subprogram address for most targets). An anonymous access-to-subprogram used as a parameter will need to be some sort of fat structure including a display or static link (and, for Janus/Ada and other generic sharing implementations, a generic instance descriptor) along with the subprogram address. You can go from thin to fat by creating the needed structures based on the type, but you can't go the other way (because you can't call a nested routine without all the stuff in the structure). ("not null" is optional of course; if you want to be able to pass null for some meaning. I use this sort of structure for debugging logging routines in my spam filter; I pass null to mean "don't log anything". So I'd omit the "not null" in that case.) Randy.