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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no 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 Path: g2news1.google.com!postnews.google.com!a26g2000vbo.googlegroups.com!not-for-mail From: Hacid Newsgroups: comp.lang.ada Subject: Re: limited /non-limited tagged type Date: Sat, 5 Mar 2011 08:48:11 -0800 (PST) Organization: http://groups.google.com Message-ID: References: <40bfb845-7868-4536-886b-496e8dc82cb4@hd10g2000vbb.googlegroups.com> NNTP-Posting-Host: 92.129.245.142 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1299343692 1008 127.0.0.1 (5 Mar 2011 16:48:12 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 5 Mar 2011 16:48:12 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: a26g2000vbo.googlegroups.com; posting-host=92.129.245.142; posting-account=WWXKmwoAAABMGIRzC01nO809MBj4MWaf User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.0; fr; rv:1.9.1.16) Gecko/20101130 Firefox/3.5.16 (.NET CLR 3.5.30729),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:17889 Date: 2011-03-05T08:48:11-08:00 List-Id: On 5 mar, 04:26, Adam Beneschan wrote: > 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 > =A0 =A0 type Object is tagged private; > =A0 =A0 procedure Copy (Dest : out Object'Class; Source : in > Object'Class); > private > =A0 =A0 type Object is tagged record ... end record; > end Foo; > > where the body of Copy says "Dest :=3D 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 :=3D 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. =A0Since it isn't really > limited, it couldn't be extended with a limited component. =A0And 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 > ":=3D". =A0I don't know if this really is what's wanted. =A0I'm sort of > guessing. =A0Anyway, 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. =A0But if it's > something like I guessed, then perhaps a Copy routine that takes > Object'Class parameters instead of Object is what is wanted. =A0And > while there's no way to get the compiler to reject other uses of :=3D , > 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. > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 -- Ad= am You perfectly understand what I want to do. And I can't explain it better than you. A good way to do that would be to derivate Object from Ada.Finalization.Controlled. But as I said I can't due to my ZFP Run Time use. I was hoping that there is an other simple way to do the same... But as Randy said I can't expect Ada to have 10 solutions to a problem. So I think I will use non limited tagged type with primitive copy operation and a rule checker to check "no assignement on Object class" rule. Thanks to yours answers and your time.