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,FREEMAIL_FROM, LOTS_OF_MONEY autolearn=ham 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-18 01:04:54 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!nntp-relay.ihug.net!usenet.net.nz!newsfeeds.ihug.co.nz!ihug.co.nz!news.xtra.co.nz!53ab2750!not-for-mail From: "AG" Newsgroups: comp.lang.ada References: Subject: Re: Private discrete type as index X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Message-ID: Date: Sat, 18 Jan 2003 22:06:31 -0800 NNTP-Posting-Host: 219.88.60.89 X-Complaints-To: newsadmin@xtra.co.nz X-Trace: news.xtra.co.nz 1042880693 219.88.60.89 (Sat, 18 Jan 2003 22:04:53 NZDT) NNTP-Posting-Date: Sat, 18 Jan 2003 22:04:53 NZDT Organization: Xtra Xref: archiver1.google.com comp.lang.ada:33168 Date: 2003-01-18T22:06:31-08:00 List-Id: wrote in message news:Im8W9.33333$1q3.5319@sccrnsc01... > > No. What I was originally trying to do was an abstraction as close > > to the array as possible (booleans do not matter of course - just > > something to put there). At the same time, I wanted to restrict > > control of the index to the package implementing it > > ... > > So, while I realise I can't (in Ada) provide things like "..", I can > > provide +/-/ operations of varying flavours on the index. This > > would keep most (not all, but most) of the array semantics in place. > > type x is new integer; > type test is array(x range <>) of boolean; > function "+"(left, right:x) return x; > function "-"(left, right:x) return x; > function "*"(left, right:x) return x; > etc. The problem with this approach is that the following is perfectly legal Ada (after you put it in a package or so of course): type x is new integer; function "+"(left, right:x) return x; a:x := 1 + 2; Now, who exactly told the user of the package that 1 & 2 are valid values for x? The declaration "new integer" of course. Please note that in one of my earlier posts in this thread this was exactly the example I gave - replacing "new integer" with "limited private". In fact, that's where it's coming from in the first place... > would give you quite a lot of control over the index. Granted you > don't have "limited" and your user can get around you via type > conversion As you could see, no [explicit] type conversions required. > , but, assuming some discipline by your user, is that > amount of control still fatally inadequate for your purposes? Well, I thought that the philosophy of Ada was *not* to assume any such thing on the part of a user. So, yes, that amount of control is inadequate.