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 Path: g2news1.google.com!postnews.google.com!r19g2000prm.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: limited /non-limited tagged type Date: Fri, 4 Mar 2011 15:34:04 -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 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1299281644 17534 127.0.0.1 (4 Mar 2011 23:34:04 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 4 Mar 2011 23:34:04 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: r19g2000prm.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: g2news1.google.com comp.lang.ada:17852 Date: 2011-03-04T15:34:04-08:00 List-Id: On Mar 4, 10:56=A0am, Hacid wrote: > Hi, > > I haven't found an existing topic about this, so I ask my question : > > I develop a package for colleagues. In this package I define a tagged > type. I want to prevent them from doing assignments on this type. But > I want to be able to do these assignments in my body. > > I understand why I can't define my type limited in the public part and > not limited in the private part. But is there a way to do what I > want ? > > Something like : > > package Foo is > > =A0 =A0type Object is tagged private; > > =A0 =A0function ":=3D" (Left : out Object,; Right : in Object) is abstrac= t; > -- I know this looks strange > > end Foo; > > Thanks. I think we might need a little more information ... First of all, why does Object have to be visibly tagged? That is, why do users of the package Foo need to see Object as tagged? I presume that this is because you want those users to be able to declare type extensions of Object. (If not, you can just declare Object as "limited private" and make the full view tagged and non-limited.) OK, so you want a user to be able to declare their own type extension: type Another_Object is new Foo.Object with record ... end record; The next question is, why do you need to assign Objects in the body of Foo? If this is to implement some operation in Foo: package Foo is type Object is tagged private; procedure Operation (X : in out Object...); or something like that, then perhaps you want Operation to be able to do an assignment operation. Here's the problem: When the user declares Another_Object, won't they probably need to declare an overriding version of Operation? And if part of Operation's purpose involves assignment, then wouldn't the overriding version of Operation also need to do assignment, in order to carry out its purpose? But you've said that you want to prevent assignment. Basically, I'm having trouble seeing how this could be the real problem. That is, even if you could declare a non-limited tagged type and remove the ":=3D" operation, in all probability I think you're going to realize that there are other problems with your design. I could be wrong. If you can explain what you're trying to accomplish, that might help point us to a solution. -- Adam