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!k15g2000prk.googlegroups.com!not-for-mail From: Edward Fish Newsgroups: comp.lang.ada Subject: Re: limited /non-limited tagged type Date: Fri, 4 Mar 2011 16:17:55 -0800 (PST) Organization: http://groups.google.com Message-ID: References: <40bfb845-7868-4536-886b-496e8dc82cb4@hd10g2000vbb.googlegroups.com> <7fa882b5-72ab-4a76-9f4c-1c303cb04858@v31g2000vbs.googlegroups.com> NNTP-Posting-Host: 174.28.181.54 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1299284275 19839 127.0.0.1 (5 Mar 2011 00:17:55 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 5 Mar 2011 00:17:55 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: k15g2000prk.googlegroups.com; posting-host=174.28.181.54; posting-account=IGEw6QoAAAChe8btAoGmJk0kqF3q3VLA User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.14) Gecko/20110218 Firefox/3.6.14 ( .NET CLR 3.5.30729; .NET4.0E),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:17856 Date: 2011-03-04T16:17:55-08:00 List-Id: On Mar 4, 2:18=A0pm, Hacid wrote: > On 4 mar, 20:54, Edward Fish wrote: > > > > > On Mar 4, 11: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 an= d > > > 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 abs= tract; > > > -- I know this looks strange > > > > end Foo; > > > > Thanks. > > > Yes, I think. > > You could add in an 'indirection step'. > > -- > package Whatever is > > =A0 =A0type Public_Type is tagged limited private; > > =A0 =A0--primitive functions. > > private > > =A0 -- Base is the type that you will manipulate in the Body. > =A0 type Base is tagged record > =A0 =A0 -- fields > =A0 =A0 =A0null; > =A0 end record; > > =A0 type Public_Type is new Base with null record; > > end Whatever; > -- > whatever.ads:15:08: completion of limited tagged type must be limited > > This way seems to not work ... :o( After reading your requirements, perhaps this would be the best way to design what you need/want: package Whatever is Type Public_Type is tagged limited private; -- Create constructs an object of Public_Type and may ONLY be used for -- initialization of objects of that type as the type is limited. Function Create( Field_1 : In Positive; Field_2 : In Integer ) Return Public_Type; -- Other primitive functions. private Type Public_Type is tagged limited record --tagged limited record -- Add fields here Null; end record; --Private/hidden functions. -- Assign may be used to copy Input to output; this includes replaceing the -- contents of a Public_Type object, which may be done like so: -- Assign( Output =3D> Variable, Input =3D> Create(1,128) ); Procedure Assign( Input : In Public_Type; Output : Out Public_Type ); end Whatever;