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,1cb75f0476fe2d1a X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!j52g2000cwj.googlegroups.com!not-for-mail From: "Jeff Carter" Newsgroups: comp.lang.ada Subject: Re: Half Constrained Array Types and Slices Date: 7 Mar 2006 11:02:49 -0800 Organization: http://groups.google.com Message-ID: <1141758169.075214.235400@j52g2000cwj.googlegroups.com> References: <1141667416.163432.304280@p10g2000cwp.googlegroups.com> <1nnb2k108agsq$.4f06q7j9rnj3$.dlg@40tude.net> NNTP-Posting-Host: 206.148.188.168 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1141758174 4964 127.0.0.1 (7 Mar 2006 19:02:54 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 7 Mar 2006 19:02:54 +0000 (UTC) User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.8) Gecko/20050511,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: j52g2000cwj.googlegroups.com; posting-host=206.148.188.168; posting-account=CRM1hQ0AAADkQdMnGSPXFDwdgNRpoxjt Xref: g2news1.google.com comp.lang.ada:3290 Date: 2006-03-07T11:02:49-08:00 List-Id: Dmitry A. Kazakov wrote: > > BTW, in the second case there is an interesting possibility, I didn't think > much about. If the language had supertyping, then the compiler could create > an anonymous supertype of the index type with one or two more values. These > imaginary values could then be returned as 'First and 'Last. The idea is > same as in IEEE's positive and negative infinities. Of course these values > could have different representation than natural index. Yet the following > will be illegal: > > I : Index := A'First; -- This may cause C_E while type conversion I suppose this could be handled much as we handle integer types, with a base type that is different from the 1st-named subtype. So a declaration such as type Single is (One); would be implemented as type Single'Base is (First, One); subtype Single is Single'Base range One .. One; Then, given type Degenerate is array (Single range <>) of Whatever; V : Degenerate (null range); we can say that V'Last is of type Single'Base. V'First = One, V'Last = First. Probably we'd do this for all enumeration types; that would allow "" for all string types. Since we define Single'Pos (One) to be zero, Single'Base'Pos (First) would have to be -1. Would that work? Or would it be better for position numbers to start at 1? -- Jeff Carter jrcarter commercial-at acm [period | full stop] org