comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: class wide iterable (and indexable)
Date: Tue, 29 Jan 2019 21:34:03 +0200
Date: 2019-01-29T21:34:03+02:00	[thread overview]
Message-ID: <gbbo56F6a0iU1@mid.individual.net> (raw)
In-Reply-To: <q2p0an$45v$2@franka.jacob-sparre.dk>

On 19-01-29 09:45 , Randy Brukardt wrote:
> "Shark8" <onewingedshark@gmail.com> 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
       .      @       .

  reply	other threads:[~2019-01-29 19:34 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-29  7:45 class wide iterable (and indexable) Randy Brukardt
2019-01-29 19:34 ` Niklas Holsti [this message]
2019-01-29 20:26   ` Dmitry A. Kazakov
  -- strict thread matches above, loose matches on Subject: below --
2019-01-02 15:48 George Shapovalov
2019-01-02 17:39 ` Simon Wright
2019-01-02 18:11   ` George Shapovalov
2019-01-03  8:52     ` Simon Wright
2019-01-03  9:30       ` George Shapovalov
2019-01-03 16:45         ` Jeffrey R. Carter
2019-01-04  4:32       ` Shark8
2019-01-05  9:03         ` Randy Brukardt
2019-01-03 22:56     ` Randy Brukardt
2019-01-04  0:00       ` George Shapovalov
2019-01-04  8:43         ` Dmitry A. Kazakov
2019-01-04 12:20           ` George Shapovalov
2019-01-05 23:29             ` Jere
2019-01-05 23:50               ` Jere
2019-01-06  9:34                 ` George Shapovalov
2019-01-06 10:19                   ` Dmitry A. Kazakov
2019-01-06 11:30                     ` George Shapovalov
2019-01-06 12:45                       ` Dmitry A. Kazakov
2019-01-06 13:18                         ` George Shapovalov
2019-01-06 14:13                           ` Dmitry A. Kazakov
2019-01-06 16:33                             ` George Shapovalov
2019-01-06 18:29                               ` George Shapovalov
2019-01-06 20:32                                 ` Dmitry A. Kazakov
2019-01-06 21:47                                   ` George Shapovalov
2019-01-07  9:37                                     ` Niklas Holsti
2019-01-07 16:24                                       ` George Shapovalov
2019-01-06 20:18                               ` Dmitry A. Kazakov
2019-01-06 21:58                                 ` George Shapovalov
2019-01-07  8:28                                   ` Dmitry A. Kazakov
2019-01-05  9:21           ` Randy Brukardt
2019-01-05 10:07             ` Dmitry A. Kazakov
2019-01-05 18:17               ` George Shapovalov
2019-01-05 20:07                 ` Simon Wright
2019-01-05 20:41                   ` George Shapovalov
2019-01-07 21:07               ` Randy Brukardt
2019-01-08  9:51                 ` Dmitry A. Kazakov
2019-01-08 19:25                   ` Björn Lundin
2019-01-08 23:26                   ` Randy Brukardt
2019-01-09 17:06                     ` Dmitry A. Kazakov
2019-01-09 23:38                       ` Randy Brukardt
2019-01-10  8:53                         ` Dmitry A. Kazakov
2019-01-10 22:14                           ` Randy Brukardt
2019-01-11  9:09                             ` Dmitry A. Kazakov
2019-01-14 22:59                               ` Randy Brukardt
2019-01-15  9:34                                 ` Dmitry A. Kazakov
2019-01-18 15:48                                   ` Olivier Henley
2019-01-18 16:08                                     ` Dmitry A. Kazakov
2019-01-18 16:29                                       ` Olivier Henley
2019-01-18 16:54                                         ` Dmitry A. Kazakov
2019-01-18 17:31                                           ` Olivier Henley
2019-01-18 18:51                                             ` Shark8
2019-01-18 20:09                                             ` Dmitry A. Kazakov
2019-01-21 23:15                                     ` Randy Brukardt
2019-01-22  8:56                                       ` Dmitry A. Kazakov
2019-01-22 22:00                                         ` Randy Brukardt
2019-01-23  8:14                                           ` Dmitry A. Kazakov
2019-01-22 17:04                                       ` Jeffrey R. Carter
2019-01-22 22:02                                         ` Randy Brukardt
2019-01-23 18:00                                           ` Jeffrey R. Carter
2019-01-23 20:14                                           ` Shark8
2019-01-23 22:47                                             ` Randy Brukardt
2019-01-24 17:11                                               ` Dmitry A. Kazakov
2019-01-28 15:54                                               ` Shark8
2019-01-28 17:23                                                 ` Dmitry A. Kazakov
2019-01-08 18:32                 ` G. B.
2019-01-05 17:05             ` Jeffrey R. Carter
2019-01-05 20:18               ` Dmitry A. Kazakov
2019-01-05 21:09               ` Shark8
2019-01-06 10:11                 ` Jeffrey R. Carter
2019-01-05 20:46             ` Shark8
2019-01-06  9:43               ` Dmitry A. Kazakov
2019-01-26 22:11 ` George Shapovalov
2019-01-26 22:14   ` George Shapovalov
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox