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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,602b7f606b0d64e2 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-01-11 04:22:26 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!fu-berlin.de!uni-berlin.de!dialin-145-254-046-055.arcor-ip.NET!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Private discrete type as index Date: Sat, 11 Jan 2003 13:22:51 +0100 Organization: At home Message-ID: References: <8pLT9.105190$hK4.8530896@bgtnsc05-news.ops.worldnet.att.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: dialin-145-254-046-055.arcor-ip.net (145.254.46.55) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: fu-berlin.de 1042287744 18509458 145.254.46.55 (16 [77047]) User-Agent: KNode/0.7.1 Xref: archiver1.google.com comp.lang.ada:32914 Date: 2003-01-11T13:22:51+01:00 List-Id: AG wrote: > package test is > > type X is new Integer; -- What I'd like here is "limited private" instead > of "new integer" > > type Test is array(X) of Boolean; > > function "+"(Left: X) return X; -- Unary increment (however that may be > implemented) > > function "+"(Left:X; N: Integer) return X; -- Shift by N positions (does > not equal N times other "+") > > private > > -- Defiinition of "X" here whatever it may be > > end test; > > The code above compiles fine. Replacing "new Integer" with "limited > private" does not. > > But, if it did, it would allow the user of the package to do things like > 10th position from > > wherever the index is now and it would be the responsibility of the > implementation > > to know what/where it is. At the same time, the client package would have > no clue > > as to what the type is or be able to operate on it directly (only through > any functions > > provided by the package which was the whole point). Ada does not have user index types other than publicly derived from discrete types. "limited private" is not such a type. You could make a sort of private type out of a discrete type by disallowing some of its predefined operations (making them abstract), but you are unable to make it limited, because ":=" is not overridable. Neither can you expose a private type as an array. Alas, ADT is far incomplete in Ada. -- Regards, Dmitry A. Kazakov www.dmitry-kazakov.de