!standard 3.5 06-11-06 AC95-00136/01 !class Amendment 06-11-06 !status received no action 06-11-06 !status received 06-07-19 !subject Ada should have elementary sets !summary !appendix [Editor's note: This appeared in an ASIS discussion, but has been filed separately because it has nothing at all to do with ASIS.] From: Tucker Taft Date: Wednesday, July 19, 2006 6:46 PM CONTINUING OFF TOPIC... I'll admit I wish I could often use "choice_list" syntax in membership tests, e.g.: if G(X) in A..B | D..F then ... and using such notation in subtype definitions would also seem to make sense. Robert Dewar wrote: > Tucker Taft wrote: >> I have certainly used ranges with enumeration types, >> but that only works if the enumeration type is >> ordered in a way that corresponds to a depth-first >> walk of some kind of hierarchical structure. > > and then works only partially, I must say it is a big > weakness of Ada that subtypes of enumerations have to > be contiguous :-( **************************************************************** From: Robert Dewar Date: Wednesday, July 19, 2006 10:02 PM I definitely agree, perhaps we will add this as an extension :-) **************************************************************** From: John Barnes Date: Thursday, July 20, 2006 1:32 AM I agree too and have done so since 1982 when first writing my book. Exercise 7.2(2) has an enumeration type type Month_Name is (Jan, Feb, Mar, ..., Dec); and then I want subtypes for the seasons. I actually write subtype Winter is Month_Name range Jan .. Mar; and so on. But that feels wrong. What I really want is winter to be December, January and February and so on. Oh dear. **************************************************************** From: Robert I. Eachus Date: Saturday, July 22, 2006 9:53 PM I'm going to say this, smile, then run and hide. If someone wants to propose this functionality for a future version of Ada, I suggest we add sets. Make *set* a reserved word, and allow users to declare sets like subtypes and use them in most of the same places. That would flag to the user that he was possibly making lots of work not for the compiler, but for the computer at run-time. It is probably worth going a bit further, and allowing values to be added to or removed from sets. You could even declare constant sets that could not be modified: constant set Digits is Character range '0'..'9' and 'A' ..'F'; --or some such. I know how easy it is to use Boolean types to implement sets in Ada, and I have done it lots of times. But it may be time to grasp the nettle, and add syntactic sugar that the compiler can convert. Of course someone is sure to point out that with all this, why not allow sets over access, tagged, and record types? As I said running and hiding. ;-) **************************************************************** From: Stephen Michell Date: Monday, July 24, 2006 3:03 AM I was going to write almost exactly that note last week, but I ran and hid before I sent it. I fully support adding sets, and not doing the range splitting that has been suggested. Dscontiguous ranges are only one of the applications of sets. The most significant issue, in my opinion, is the name choice. "set" is the most obvious choice, and probably the only choice, but is likely a type name in 1/2 the Ada programs in the worls. **************************************************************** From: Robert Dewar Date: Wednesday, July 26, 2006 1:31 AM To me the range splitting is a simple extension, syntactically and semantically, and we even think of doing this as an extension. But adding sets is a very big language design step, I doubt it will ever happen! One related issue we have considered is a pragma that would say that an enumeration type is unordered, and prohibit any constructs that depend on the ordering (incoluding comparison and subranges). ****************************************************************