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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!feeder.erje.net!1.eu.feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: class wide iterable (and indexable) Date: Tue, 29 Jan 2019 21:34:03 +0200 Organization: Tidorum Ltd Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net kxBr8Wgte0/Kga5oiDSvdAxoGK6e5Tu15Z3h2xCSiKLYWU8noB Cancel-Lock: sha1:hHnLFmogb85M+EvNwCzjcx0ZrtA= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 In-Reply-To: Xref: reader01.eternal-september.org comp.lang.ada:55403 Date: 2019-01-29T21:34:03+02:00 List-Id: On 19-01-29 09:45 , Randy Brukardt wrote: > "Shark8" wrote in message > news:f4c1e192-9a24-40d1-abd1-233ef6087658@googlegroups.com... >> On Wednesday, January 23, 2019 at 3:47:43 PM UTC-7, Randy Brukardt wrote: >>> "Shark8" wrote in message >>> news:9eedf818-8bfb-465b-afe5-aa3fb0525948... >>>> Wouldn't this be a non-issue if we could Static_Predicate Array-types >>>> like >>>> so? >>>> >>>> Type Some_String is Array(Positive range <>) of Character >>>> with Static-Predicate => Some_String'First = 1; >>> >>> The idea of a static predicate is for them to stand-in for proper set >>> constraints (I would have preferred the latter, but I was alone on that), >>> so >>> they don't have anything to do with array bounds. >> >> What do you mean by "proper set constraints"? [And how would they look?] >> Things like {x| x in {2**y where y in 0..15} }? (X in >> 1|2|4|8|16|..|32_768) > > See AI05-0153-2. The idea was that there was a kind of constraint that > represented a set. I used "when" in the syntax to reflect a case statement > limb: > > subtype Odd is Natural when 1|3|5|7|9; > > The main difference semantically from static predicates was that these > actually changed the value set, which eliminated (at least in my mind) the > oddities with 'First and 'Last that occur for predicates. Otherwise, their > pretty much the same (including the banning of arrays and slices to > eliminate discontiguous arrays). Another approach to the same (?) could be to allow enumerated types where the literals are integers, as in: type Odd is (1, 3, 5, 7, 9); -- NOT current Ada! This is no weirder than the current enumerated types where the literals are characters, as in the well-known example of Roman numbers. And then -- hey presto! -- we connect to the thread about enumeration representations and gappy representations, where arrays and slices _are_ allowed ... so the same compiler machinery could be reused for "integer enumeration" types, no? Of course one would have to be careful how (and if) the arithmetic operators are defined for "integer enumeration" types. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .