comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: What would you like in Ada202X?
Date: Mon, 7 May 2012 19:48:05 -0500
Date: 2012-05-07T19:48:05-05:00	[thread overview]
Message-ID: <jo9qg9$qub$1@munin.nbi.dk> (raw)
In-Reply-To: a0r0vkFb94U1@mid.individual.net

"Niklas Holsti" <niklas.holsti@tidorum.invalid> wrote in message 
news:a0r0vkFb94U1@mid.individual.net...
> On 12-05-07 09:33 , ytomino wrote:
>> It's interesting.
>>
>> What would happen to 'Pos and 'Val ?
>
> They would work in the normal way for enumeration types, just as if the 
> parent type and the derived type were declared separately, without 
> derivation.
>
>>>   type Message_Kind1 is (Sign_On, Request, Reply, Sign_Off);
>>>   type Detailed_Message_Kind is new Message_Kind1 with (
>>>        Request =>  (Read, Write),
>>>        Reply   =>  (Data, Ack, Refused),
>>>        others  =>  <>);
>>
>> First, Message_Kind1'Pos (Sign_On) = 1, Request = 2, Reply = 3, Sign_Off 
>> = 4, of course.
>
> That should be 0, 1, 2, and 3. 'Pos starts from zero.
>
>> 1) To keep order, Detailed_Message_Kind'Pos (Read) = 2, Write = 2.5 
>> (float!)
>
> No, I would make the 'Pos values for Detailed_Message_Kind be the normal 
> ones for its list of literals: Detailed_Message_Kind'Pos for Sign_On is 0, 
> for Read it is 1, for Write it is 2, for Data it is 3, for Ack it is 4, 
> for Refused it is 5, and for Sign_Off it is 6.
>
> I don't see any reason to keep the same position number for the "same" 
> literal of Message_Kind1 and of Detailed_Message_Kind. Although the 
> literals have the same identifier, they are not the same value.

But the representation of an enumeration type is its position number, unless 
otherwise specified. That's an age-old Ada requirement (found in 13.4(8)). I 
suppose you could drop it, but then a complete replacement would have to be 
defined and that would be complex (and less than useful).

...
>> It seems difficult to realize keeping operator "<",">" and keeping
>> Message_Kind1'Pos (X) = Detailed_Message_Kind'Pos (X) at same time.
>
> The code for the relational operators "<" and ">" would use the 
> representation, not the position number. I suggested that values of the 
> derived type would be represented by some "parent" bits that represent a 
> value of the parent type, and some more "extension bits" to separate the 
> refining literals from each other. If these bits are packed in a word, 
> with the extension bits less significant than the parent bits, ordinary 
> integer comparison instructions can implement "<" and ">" for the derived 
> type. (This is just like lexicographic ordering.)

This makes no sense, since enumerations have well-defined representations, 
which can be specified by the user. And it provides no value that I can see, 
since a compiler is going to have to support conversions to/from these 
enumerations that have user-defined representations anyway. So the only way 
to do the conversions is is with a lookup table.

Moreover, I can't speak for other compilers, but Janus/Ada uses the position 
number for all operations; the only use of the representation is to 
read/store from memory. So the representation is completely irrelevant for 
implementing operations. (We wouldn't even need to enforce the 
representation ordering rules, but of course we do because they're required 
by the language.) We couldn't find any reasonable way to support operations 
like indexing and looping and still support arbitrary representations with 
missing values (holes if you will).

>> And it's unclear about representation of "array (Detailed_Message_Kind) 
>> of ...".

Arrays in Ada should not have holes, so the representation would surely not 
change.

> The array index would be the position number, as usual. The position 
> number can be computed from the representation with parent bits and 
> extension bits. To make this computation fast,

This isn't happening, because of the need to support user-specified 
representations. That's not "fast", and it's almost certain that 
implementations would use the same mechanism for this (why invent a third 
mechanism for something rarely used?).

...
>> However, I too want to use this extensible enum if you have a nice 
>> solution.
>
> Two votes in favour, interesting!

It seemed like a useful idea back in the day, but to be really useful, we 
need the equivalent of class-wide operations. I don't see how to do that if 
the position numbers are completely different between the various types. So 
I'm dubious, but we have a long time before any of this is going to be 
adopted, so perhaps improvements can be made.

                                    Randy.





  reply	other threads:[~2012-05-08  0:48 UTC|newest]

Thread overview: 312+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-25  7:47 What would you like in Ada202X? Martin
2012-04-25  8:01 ` Yannick Duchêne (Hibou57)
2012-04-25  8:30   ` stefan-lucks
2012-04-25 19:21   ` Adam Beneschan
2012-04-28 11:50   ` Yannick Duchêne (Hibou57)
2012-04-28 13:21   ` Yannick Duchêne (Hibou57)
2012-04-29  1:03     ` BrianG
2012-04-25  8:36 ` Jacob Sparre Andersen
2012-04-25  8:46   ` Yannick Duchêne (Hibou57)
2012-04-25  9:04     ` leonid
2012-04-25 11:30     ` Jacob Sparre Andersen
2012-04-26  2:00       ` Randy Brukardt
2012-04-26 13:10         ` AdaMagica
2012-04-26 15:49       ` anon
2012-04-27  0:26         ` Randy Brukardt
2012-04-25  9:10   ` Martin
2012-04-25  8:36 ` Dmitry A. Kazakov
2012-04-25  8:59   ` Yannick Duchêne (Hibou57)
2012-04-25  9:24     ` Dmitry A. Kazakov
2012-04-25 10:05       ` Yannick Duchêne (Hibou57)
2012-04-26  2:08       ` Randy Brukardt
2012-04-26  8:50         ` Dmitry A. Kazakov
2012-04-26 23:50           ` Randy Brukardt
2012-04-27  5:03             ` Yannick Duchêne (Hibou57)
2012-04-27 13:50               ` Robert A Duff
2012-04-27 23:25               ` Randy Brukardt
2012-04-28  6:32                 ` Yannick Duchêne (Hibou57)
2012-04-27  7:56             ` Dmitry A. Kazakov
2012-04-27 13:56               ` Robert A Duff
2012-04-28  8:32                 ` Dmitry A. Kazakov
2012-04-28 11:44                   ` Yannick Duchêne (Hibou57)
2012-04-29 13:35                   ` Robert A Duff
2012-04-29 15:59                     ` Dmitry A. Kazakov
2012-04-29 19:27                       ` Robert A Duff
2012-04-29 20:09                         ` Dmitry A. Kazakov
2012-05-01  2:17                     ` Randy Brukardt
2012-04-25  9:31   ` Dmitry A. Kazakov
2012-04-26  2:10     ` Randy Brukardt
2012-05-10  7:29   ` Gustaf Thorslund
2012-05-14  9:25     ` stefan-lucks
2012-05-14 12:19       ` Dmitry A. Kazakov
2012-05-14 13:09         ` Georg Bauhaus
2012-05-14 13:40           ` Dmitry A. Kazakov
2012-05-14 15:50             ` Georg Bauhaus
2012-05-14 20:24               ` Gustaf Thorslund
2012-05-14 22:49                 ` tmoran
2012-05-15  6:15                   ` Gustaf Thorslund
2012-04-25  9:09 ` Georg Bauhaus
2012-04-25  9:14   ` Yannick Duchêne (Hibou57)
2012-04-25  9:30   ` Dmitry A. Kazakov
2012-04-25 13:11   ` Marc C
2012-04-25 13:35     ` Georg Bauhaus
2012-04-25 13:36     ` Pascal Obry
2012-04-25 14:18     ` Yannick Duchêne (Hibou57)
2012-04-25 16:12     ` björn lundin
2012-04-25 17:36       ` Lucretia
2012-04-25 20:26         ` Yannick Duchêne (Hibou57)
2012-04-26 15:20       ` Simon Wright
2012-04-28 10:58         ` björn lundin
2012-04-26 12:37     ` Marc C
2012-04-25 18:14   ` Jeffrey Carter
2012-04-25 18:51     ` Dmitry A. Kazakov
2012-04-25 20:53     ` Yannick Duchêne (Hibou57)
2012-04-25 21:14       ` Jeffrey Carter
2012-04-25 21:27         ` Yannick Duchêne (Hibou57)
2012-04-25 21:30         ` Yannick Duchêne (Hibou57)
2012-04-25 22:33           ` Jeffrey Carter
2012-04-26  0:50             ` Yannick Duchêne (Hibou57)
2012-04-26  1:06               ` Jeffrey Carter
2012-04-28 11:02               ` okellogg
2012-04-28 11:48                 ` Yannick Duchêne (Hibou57)
2012-04-29 13:43                 ` Robert A Duff
2012-04-29 16:59                   ` okellogg
2012-04-29 19:04                     ` Robert A Duff
2012-04-29 19:32                       ` Yannick Duchêne (Hibou57)
2012-04-29 19:37                       ` Yannick Duchêne (Hibou57)
2012-04-29 19:55                         ` Robert A Duff
2012-04-29 21:37                       ` okellogg
2012-04-29 22:51                         ` Robert A Duff
2012-04-26  2:23   ` Randy Brukardt
2012-04-26  8:25     ` Dmitry A. Kazakov
2012-04-26 23:58       ` Randy Brukardt
2012-04-27  7:23         ` Dmitry A. Kazakov
2012-04-27 22:42           ` Randy Brukardt
2012-04-28  7:53             ` Dmitry A. Kazakov
2012-04-28 11:40               ` Yannick Duchêne (Hibou57)
2012-04-28 11:51                 ` Dmitry A. Kazakov
2012-05-01  2:32               ` Randy Brukardt
2012-04-27  7:41   ` Jacob Sparre Andersen
2012-04-27 15:33     ` Adam Beneschan
2012-04-29  7:57     ` J-P. Rosen
2012-04-29 17:32       ` Robert Love
2012-04-29 23:33       ` Shark8
2012-05-10  7:18   ` ytomino
2012-05-10 15:25     ` Adam Beneschan
2012-05-10 15:51       ` ytomino
2012-05-10 17:09         ` Adam Beneschan
2012-05-10 18:25           ` ytomino
2012-04-25 12:13 ` Georg Bauhaus
2012-04-25 16:41   ` tmoran
2012-04-25 13:10 ` Nicholas Paul Collin Gloucester
2012-04-25 18:10   ` Zhu Qun-Ying
2012-04-25 18:07 ` okellogg
2012-04-25 19:15   ` Adam Beneschan
2012-04-25 20:12     ` okellogg
2012-04-25 20:26       ` Jeffrey Carter
2012-04-25 21:09         ` Yannick Duchêne (Hibou57)
2012-04-25 21:11         ` Martin Dowie
2012-04-25 22:18           ` Georg Bauhaus
2012-04-26  2:36             ` Randy Brukardt
2012-04-25 20:40       ` Adam Beneschan
2012-04-25 22:05         ` okellogg
2012-04-25 23:13           ` Adam Beneschan
2012-04-26  1:46             ` Brad Moore
2012-04-26  2:41             ` Randy Brukardt
2012-04-26  7:43         ` Mart van de Wege
2012-04-26  8:46           ` Georg Bauhaus
2012-04-26 14:57             ` Mart van de Wege
2012-04-26 15:28           ` Adam Beneschan
2012-04-26 18:16           ` Jeffrey Carter
2012-04-26 21:41             ` Mart van de Wege
2012-04-26 22:01               ` Jeffrey Carter
2012-04-25 20:19     ` Jeffrey Carter
2012-04-25 21:05   ` Yannick Duchêne (Hibou57)
2012-04-26  2:33   ` Randy Brukardt
2012-04-25 18:24 ` Jeffrey Carter
2012-04-25 19:02   ` Dmitry A. Kazakov
2012-04-25 19:02 ` Oliver Kleinke
2012-04-25 19:27   ` Dmitry A. Kazakov
2012-04-25 20:50   ` Georg Bauhaus
2012-04-26  8:15     ` Oliver Kleinke
2012-04-26  9:16       ` Jacob Sparre Andersen
2012-04-26  9:16       ` Georg Bauhaus
2012-04-25 21:17   ` Yannick Duchêne (Hibou57)
2012-04-26  8:18     ` Oliver Kleinke
2012-04-25 22:14 ` ytomino
2012-04-26  0:37   ` Yannick Duchêne (Hibou57)
2012-04-26  2:52     ` Randy Brukardt
2012-04-26 15:19       ` Adam Beneschan
2012-04-26 15:55         ` Dmitry A. Kazakov
2012-04-27  2:38         ` ytomino
2012-04-27  8:09           ` Georg Bauhaus
2012-04-27  8:19             ` Dmitry A. Kazakov
2012-04-27  9:46               ` Georg Bauhaus
2012-04-27 10:05                 ` Dmitry A. Kazakov
2012-04-27 11:04                   ` Georg Bauhaus
2012-04-27 12:10                     ` Dmitry A. Kazakov
2012-04-26  4:12     ` ytomino
2012-04-26  8:44     ` Dmitry A. Kazakov
2012-04-26 11:22       ` Yannick Duchêne (Hibou57)
2012-04-26 13:17         ` Dmitry A. Kazakov
2012-04-27  0:09       ` Randy Brukardt
2012-04-27  5:23         ` Yannick Duchêne (Hibou57)
2012-04-27 22:49           ` Randy Brukardt
2012-04-27  7:31         ` Dmitry A. Kazakov
2012-04-27 22:46           ` Randy Brukardt
2012-04-28  8:41             ` Dmitry A. Kazakov
2012-04-25 22:30 ` Shark8
2012-04-26  0:42   ` Yannick Duchêne (Hibou57)
2012-04-26  9:29 ` gautier_niouzes
2012-04-26 11:27   ` Yannick Duchêne (Hibou57)
2012-04-26 13:19     ` Dmitry A. Kazakov
2012-04-30 22:38     ` gautier_niouzes
2012-04-27  0:18 ` sbelmont700
2012-04-27 16:04   ` Shark8
2012-04-27 21:11     ` sbelmont700
2012-04-27 23:18       ` Randy Brukardt
2012-04-27 23:40         ` sbelmont700
2012-04-28  2:17           ` Adam Beneschan
2012-04-28  8:03           ` Dmitry A. Kazakov
2012-04-29  3:20       ` Shark8
2012-04-29 15:42         ` sbelmont700
2012-04-29 23:29           ` Shark8
2012-04-30  2:00             ` sbelmont700
2012-04-27 23:03   ` Randy Brukardt
2012-04-27  5:10 ` Nasser M. Abbasi
2012-04-27  5:36   ` Yannick Duchêne (Hibou57)
2012-04-27 10:59 ` Martin
2012-04-27 17:05   ` Simon Wright
2012-04-30  7:28     ` Martin
2012-05-01  2:45       ` Randy Brukardt
2012-05-01  7:28         ` Martin
2012-05-01 17:15           ` Shark8
2012-05-01 18:13             ` Jeffrey Carter
2012-05-01 19:30             ` Dmitry A. Kazakov
2012-05-01 20:23             ` Robert A Duff
2012-05-01 21:53               ` tmoran
2012-05-01 22:05                 ` Adam Beneschan
     [not found]                   ` <JYOdnei1xPFt8D3SnZ2dnUVZ_qudnZ2d@earthlink.com>
2012-05-02  4:28                     ` Shark8
2012-05-02  8:18             ` Martin
2012-05-02 12:57               ` Shark8
2012-05-08 17:45             ` Martin Dowie
2012-05-03 15:30           ` gautier_niouzes
2012-05-03 15:58             ` Yannick Duchêne (Hibou57)
2012-05-04  7:25               ` Martin
2012-05-01 16:23         ` Simon Wright
2012-04-29  3:52   ` Shark8
2012-04-29  7:13     ` Dmitry A. Kazakov
2012-04-29  9:17       ` gautier_niouzes
2012-04-27 15:33 ` mjsilva
2012-04-28  1:38   ` BrianG
2012-05-01 15:04     ` mjsilva
2012-04-30  6:28 ` Michael Rohan
2012-04-30  6:40 ` Michael Rohan
2012-04-30  8:27   ` Yannick Duchêne (Hibou57)
2012-05-06 18:48 ` Niklas Holsti
2012-05-06 19:27   ` Simon Wright
2012-05-06 20:47     ` Niklas Holsti
2012-05-06 19:28   ` Dmitry A. Kazakov
2012-05-06 20:06     ` Yannick Duchêne (Hibou57)
2012-05-06 21:26     ` Niklas Holsti
2012-05-07  7:49       ` Dmitry A. Kazakov
2012-05-07 23:18         ` Niklas Holsti
2012-05-08  9:03           ` Dmitry A. Kazakov
2012-05-08 19:20             ` Niklas Holsti
2012-05-08 19:44               ` Niklas Holsti
2012-05-09  8:02               ` Dmitry A. Kazakov
2012-05-10  0:47                 ` Randy Brukardt
2012-05-13 19:53                   ` Niklas Holsti
2012-05-15  6:30                     ` Randy Brukardt
2012-05-15  7:58                       ` Dmitry A. Kazakov
2012-05-16  0:05                         ` Randy Brukardt
2012-05-17 19:48                       ` Niklas Holsti
2012-05-18  4:28                         ` Randy Brukardt
2012-05-17 14:40                 ` Niklas Holsti
2012-05-17 17:12                   ` Dmitry A. Kazakov
2012-05-07  6:33   ` ytomino
2012-05-07 22:34     ` Niklas Holsti
2012-05-08  0:48       ` Randy Brukardt [this message]
2012-05-08  6:30         ` Niklas Holsti
2012-05-08 22:11           ` Randy Brukardt
2012-05-08 22:22           ` Randy Brukardt
2012-05-09  7:18             ` Dmitry A. Kazakov
2012-05-10  0:30               ` Randy Brukardt
2012-05-10  7:44                 ` Dmitry A. Kazakov
2012-05-10 21:22             ` Niklas Holsti
2012-05-11  7:39               ` Dmitry A. Kazakov
2012-05-12  0:11               ` Randy Brukardt
2012-05-15 21:35                 ` Niklas Holsti
2012-05-16  0:19                   ` Randy Brukardt
2012-05-17 22:01                     ` Niklas Holsti
2012-05-18  4:35                       ` Randy Brukardt
2012-05-16  7:39                   ` Dmitry A. Kazakov
2012-05-10  6:45       ` ytomino
2012-05-15 21:52         ` Niklas Holsti
2012-07-03 15:41   ` Pascal Obry
2012-07-03 15:50     ` Pascal Obry
2012-07-04 11:41       ` Ada novice
2012-07-04 12:30         ` Nasser M. Abbasi
2012-07-04 17:05           ` shai.lesh
2012-07-04 17:55           ` Simon Wright
2012-07-04 18:35             ` Nasser M. Abbasi
     [not found]             ` <0o59v7djiffnl7sqdpp2uiso78oa9hb8sb@invalid.netcom.com>
2012-07-04 20:34               ` shai.lesh
2012-07-04 22:26                 ` Simon Wright
     [not found]                   ` <j5p9v7l646mlk9m073u4m69dg3gjfjblfm@invalid.netcom.com>
2012-07-05  7:53                     ` shai.lesh
2012-07-05  8:18                       ` Simon Wright
2012-07-06  0:48                         ` John B. Matthews
2012-07-05  8:30                       ` georg bauhaus
2012-07-05 11:57                         ` shai.lesh
2012-07-05 12:11                           ` Nasser M. Abbasi
2012-07-05 12:21                             ` Nasser M. Abbasi
2012-07-05 13:07                               ` shai.lesh
2012-07-05 14:08                                 ` Nasser M. Abbasi
2012-07-05 15:51                                   ` Ada novice
2012-07-05 15:55                   ` johnscpg
2012-07-05 16:57                     ` Simon Wright
2012-07-05 17:36                       ` shai.lesh
2012-07-06 12:07                       ` Ada novice
2012-07-06 15:29                         ` Simon Wright
2012-07-12  6:02                           ` Egil Høvik
2012-07-12  8:29                             ` Simon Wright
2012-07-12  9:00                               ` Egil Høvik
2012-07-12 12:44                                 ` Georg Bauhaus
2012-07-12 13:20                                   ` Egil Høvik
2012-07-12 15:53                                   ` Adam Beneschan
2012-07-12 16:34                                     ` Dmitry A. Kazakov
2012-07-12 17:35                                     ` Georg Bauhaus
2012-07-19  6:44                                     ` David Thompson
2012-07-19 18:22                                       ` Simon Wright
2012-07-20  6:20                                         ` Georg Bauhaus
2012-07-27 19:49                                           ` Ada novice
2012-07-12  9:47                               ` Nasser M. Abbasi
2012-05-10 13:13 ` Martin
2012-05-18  9:56 ` Marius Amado-Alves
2012-06-04  8:10 ` Yannick Duchêne (Hibou57)
2012-06-11 21:54 ` Yannick Duchêne (Hibou57)
2012-06-29 11:29 ` joachim.schroeer
2012-06-29 11:54   ` AdaMagica
2012-06-29 12:42     ` stefan-lucks
2012-06-29 15:12     ` Adam Beneschan
2012-07-03  0:47     ` Randy Brukardt
2012-06-29 12:13   ` Dmitry A. Kazakov
2012-06-29 22:37     ` Robert A Duff
2012-06-30 12:00 ` Brian Drummond
2012-06-30 12:34   ` Dmitry A. Kazakov
2012-06-30 17:00     ` Brian Drummond
2012-06-30 18:43       ` Dmitry A. Kazakov
2012-06-30 21:06         ` Brian Drummond
2012-07-01  8:17           ` Oliver Kellogg
2012-07-01  8:28             ` Pascal Obry
2012-07-01  8:25           ` Dmitry A. Kazakov
2012-07-01 10:57             ` Brian Drummond
2012-07-01 12:46               ` Dmitry A. Kazakov
2012-07-03  0:53               ` Randy Brukardt
2012-06-30 15:51   ` Robert A Duff
2012-06-30 17:37     ` Brian Drummond
2012-06-30 18:09       ` Robert A Duff
2012-06-30 18:26       ` Niklas Holsti
2012-07-01 10:47         ` Brian Drummond
2012-07-13  8:07 ` Martin
2012-07-13 11:04   ` Pascal Obry
2012-07-13 11:13     ` Martin
replies disabled

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