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.8 required=5.0 tests=BAYES_00,INVALID_DATE, MSGID_SHORT autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!watmath!clyde!att!rutgers!mit-eddie!uw-beaver!cornell!batcomputer!itsgw!steinmetz!uunet!mcvax!enea!sommar From: sommar@enea.se (Erland Sommarskog) Newsgroups: comp.lang.ada Subject: Sets in Ada Message-ID: <4124@enea.se> Date: 3 Dec 88 22:36:50 GMT Organization: ENEA DATA AB, Sweden List-Id: Ray Trent (trent@unix.sri.com) writes: >Another change I'd like to see. (upward compatible this time) Allow: > > if A in B | C | D | Q | Y | N then > ... > end if; > >I.e. an extension of the membership idea. It's ridiculous to me that Although it would be nice to have in the language as such, it is fairly easy to write your own generic Set package. I include some excerpts from my own: Generic Type Element is (<>); Package Set_handler is Type Set_type is private; Empty_set : Constant Set_type; Type Element_array is array(integer range <>) of Element; Function Set(Elem : Element) return Set_type; Function Set(Elems : Element_array) return Set_type; -- A set of all compontens in Elems. Function Set(From, To : Element) return Set_type; -- A set of the range From..To. ... Function In_set(Elem : Element; A : Set_type) return boolean; Instantiate that on your favourite enumarate and you can write: IF In_set(A, Set((B, C, D, Y, Z))) THEN Somewhat obscure, agreed. (It would have been nice here if the IN operator had been overloadable.) -- Erland Sommarskog ENEA Data, Stockholm sommar@enea.se "Frequently, unexpected errors are entirely unpredictable" - Digital Equipment