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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8276b2994037cd71 X-Google-Attributes: gid103376,public From: Lao Xiao Hai Subject: Re: disjoint ranges ? Date: 2000/10/13 Message-ID: <39E7BB80.1AB10FE2@ix.netcom.com>#1/1 X-Deja-AN: 681226331 Content-Transfer-Encoding: 7bit References: <39E612C9.9BF98CD3@laas.fr> <39E79F17.24DB0828@pacbell.net> X-Accept-Language: en X-Server-Date: 14 Oct 2000 01:53:33 GMT Content-Type: text/plain; charset=us-ascii Organization: MindSpring Enterprises Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 2000-10-14T01:53:33+00:00 List-Id: wayne lydecker wrote: > >How about using a boolean array: > > with Text_IO; > procedure lunch is > type Hours is new Integer range 0 .. 23 ; > Lunch_Hours : array (Hours) of Boolean := > (7..9 => True, 12..14 => True, 19..21 => True, others => False); > begin > if Lunch_Hours(7) then > text_io.put_line("Lunch time"); > else > text_io.put_Line("Get back to work"); > end if; > end; This is one of those, "I can find a way to do it in my language," examples. We can ultimately solve any programming problem in any programming language (Yes, I exaggerate slightly), but this returns us to the issue of expressiveness versus expressibility. Certain languages are more expressive of certain problems. They directly map the solution space to the problem space. The original post, if I read it correctly, was not concerned with the question, "Can such and such be accomplished," but rather, "Is there a syntax to directly express the solution to the given problem?" Pat Rogers candidly and succinctly answered, "No." That was a correct answer. There are some in the world of object technology who believe that enumerated types are a bad idea because they are an artifact of an old-fashioned style of programming. This same criticism could be leveled at the whole issue of range constraints. While the notion of a range constraints was a good one when first introduced, it could be argued that the problem addressed by a range constraint better can be solved with assertions. An assertion would enable easy modeling of non-contiguous ranges. Of course, this also makes the compiler a bit more complicated and introduces other problems. The question is whether the new problems are worse than the old one being solved. I coming to believe more and more that an assertion model, similar to that in Eiffel, would be a worthwhile capability of the next Ada standard. At the same time, perhaps the new standard should make obsolescent some of the outmoded ideas(e.g., variant records) that are anachronistic in the contemporary world of OOP. Just a little old-fashioned heresy on a warm Saturday evening in California. Richard Riehle