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-Thread: 103376,1cb75f0476fe2d1a X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!news.belwue.de!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Half Constrained Array Types and Slices Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1141667416.163432.304280@p10g2000cwp.googlegroups.com> <1nnb2k108agsq$.4f06q7j9rnj3$.dlg@40tude.net> <1141758169.075214.235400@j52g2000cwj.googlegroups.com> Date: Wed, 8 Mar 2006 15:29:07 +0100 Message-ID: <2f9u4hapikva$.12yh8b4eimcb8$.dlg@40tude.net> NNTP-Posting-Date: 08 Mar 2006 15:29:08 MET NNTP-Posting-Host: 9ffb9ed7.newsread2.arcor-online.net X-Trace: DXC=h1TCVP`YdP?j12nnM8XB1>Q5U85hF6f;4jW\KbG]kaM8ZmYl>WOG@=5I[l:ilTIH?9[6LHn;2LCV>7enW;^6ZC`4IXm65S@:3>? X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:3294 Date: 2006-03-08T15:29:08+01:00 List-Id: On 7 Mar 2006 11:02:49 -0800, Jeff Carter wrote: > 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? Maybe it will work. At least it looks consistent. An interesting related question is: type Single is (One); for Single'Size use 0; -- Can I have it really 0? -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de