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,2586a992fd399bf8 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!y31g2000prd.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: limited /non-limited tagged type Date: Fri, 4 Mar 2011 19:26:48 -0800 (PST) Organization: http://groups.google.com Message-ID: References: <40bfb845-7868-4536-886b-496e8dc82cb4@hd10g2000vbb.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1299295608 30261 127.0.0.1 (5 Mar 2011 03:26:48 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 5 Mar 2011 03:26:48 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: y31g2000prd.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618; .NET4.0C),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:18836 Date: 2011-03-04T19:26:48-08:00 List-Id: After looking more closely at the OP's example code, I can think of a possible case where one *could* argue that a new feature in Ada would be useful, although I think it's way too obscure to consider adding anything like this. package Foo is type Object is tagged private; procedure Copy (Dest : out Object'Class; Source : in Object'Class); private type Object is tagged record ... end record; end Foo; where the body of Copy says "Dest := Source" and maybe performs some other functions. It wouldn't work to make the partial view of Object limited, because then another package could extend Object by adding a component of limited type to it, and then Dest := Source, when given objects of that new type, would copy a limited component, which is a no-no. However, ***IF*** Ada had a way to say that Object isn't really limited but still doesn't have assignment visibly defined (i.e. partially limited??), then things might work. Since it isn't really limited, it couldn't be extended with a limited component. And it would accomplish the purpose that the OP seems to want: forcing other packages to use the Copy operation (which wouldn't be overridden, but would still copy all the components in any type extension) instead of ":=". I don't know if this really is what's wanted. I'm sort of guessing. Anyway, I think the chance of a feature like this being added is somewhere between zero and less than zero, and I'm certainly not going to propose one. I'd still need more info on just what the OP's needs are. But if it's something like I guessed, then perhaps a Copy routine that takes Object'Class parameters instead of Object is what is wanted. And while there's no way to get the compiler to reject other uses of := , there's a way to make them blow up at runtime: add a component to Object whose type is derived from Ada.Finalization.Controlled, and define an Adjust routine that raises an exception unless a Boolean flag in the body of Foo is set, and of course Copy would be the only routine that sets it. -- Adam