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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5117b1b6391a0e06 X-Google-Attributes: gid103376,public Path: g2news1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: A simple ADA puzzle (I haven't the answer) Date: Fri, 25 Jun 2004 10:24:26 +0200 Message-ID: References: <1087410710.477506@master.nyc.kbcfp.com> <1087474761.60413@master.nyc.kbcfp.com> <7o83d0hf6sqgng2980e1tg7iu864m5m50u@4ax.com> <1in5d05aa4rfqlt7e76gk87ucd3vuru6pm@4ax.com> <1087564576.388973@master.nyc.kbcfp.com> <1087575262.304708@master.nyc.kbcfp.com> <2i5dd0lu0i3a8bokfh7916r4j67g42ri4o@4ax.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de Frye5VfIJZjtCT5VpXrnWQVpRH3c9FK62p492kKBLrFzyjos8= User-Agent: 40tude_Dialog/2.0.12.1 Xref: g2news1.google.com comp.lang.ada:1878 Date: 2004-06-25T10:24:26+02:00 List-Id: On Thu, 24 Jun 2004 15:53:33 -0500, Randy Brukardt wrote: > "Dmitry A. Kazakov" wrote in message > news:pltjvkdjp69c.11hhxh2y8idq9.dlg@40tude.net... >> On Wed, 23 Jun 2004 16:37:01 -0500, Randy Brukardt wrote: >> >>> "Dmitry A. Kazakov" wrote in message >>> news:2i5dd0lu0i3a8bokfh7916r4j67g42ri4o@4ax.com... >>> ... >>>>>As I have said, it's extremely simple. Automatic variables are > invisible. >>>> >>>> Huh, how is it better than Ada's limitation on tagged types? >>> >>> The only limitation on tagged types in Ada 2005 is that you can't extend > a >>> formal type in a generic body. See AI-344, approved in Palma de > Mallorca. >>> (There are accessibility checks if you try pass an object of a nested > type >>> outwards.) >> >> But I will be still able to allocate it, return a class-wide pointer and >> then to dispatch to an out-of-scope subroutine. It seems that some >> additional overhead will be needed to catch that. > > No. The conversion to the class-wide pointer (presumably global) would fail > its accessibility check. So the program would be illegal. No overhead > needed. I see. I hope that Unchecked_Conversion on such pointers and all sorts of games with 'Unchecked_Access on views will be also illegal. > Tucker's idea was simply to move the accessibility checks from the > declaration of the type (the Ada 95 rule) to the uses of the objects (which > turn out to be only a handful of places). > > It is true that dispatching to an overridden routine for a type in a nested > scope will be more expensive (there will be a wrapper to set the static link > or display properly). But that's a small price to pay for something that you > can't do at all now. (And it won't make any existing code slower, > obviously.) > >> BTW, there could be alternatives to accessibility checks, when overhead is >> accepted. For example, one could forcibly upcast objects if their type > goes >> out of scope. > > Silent truncation (upcasting) of a type was considered a very bad thing > during the design of Ada 95. Anything that would require that (such has > having both statically and dynamically tagged operands in a single call - > see 3.9.2(8)) is illegal. > > You could argue whether that is a good idea I would not. Tags should be constant that is almost sacral to me. (:-)) But only if objects are by-reference, which is the case anyway. But if some day Ada will allow by-value tagged objects, then ... > or not, but I don't think that > we're going to change that part of the philosophy. -- Regards, Dmitry A. Kazakov www.dmitry-kazakov.de