Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!mcvax!ukc!etive!lfcs!db From: db@lfcs.ed.ac.uk (Dave Berry) Newsgroups: comp.lang.eiffel Subject: Re: Multi-branch instructions and unique values (Version 2.2 preview) Keywords: Case, Enumeration Message-ID: <1638@etive.ed.ac.uk> Date: 24 Mar 89 17:43:00 GMT References: <122@eiffel.UUCP> Sender: news@etive.ed.ac.uk Reply-To: db@lfcs.ed.ac.uk (Dave Berry) Organization: Laboratory for the Foundations of Computer Science, Edinburgh U Lines: 45 In article <122@eiffel.UUCP> bertrand@eiffel.UUCP (Bertrand Meyer) writes: > > For test constants declared explicitly (not >``unique''), a notational facility is offered: a sequence of >consecutive explicit values, such as 3, 4, 5 or 'a', 'b', >'c', 'd' may be abbreviated as an interval, written in the >form min..max, as in one of the following: > > 3..5 > > 'a'..'d' Would it not be possible to extend this notational fcility to unique constants declared in the same declararion? To use Bertrand's example: > blue, white, red: INTEGER is unique; If this notation were taken to mean that the unique values given to blue, white and red must be consecutive, tests could be made against the ranges blue..white, white..red and blue..red. In a small example like this, it isn't too useful, but it might be useful with a larger case. Alternatively, since all unique constants in a test must be defined in the same class, one could define all unique constants defined in the same class to be consecutive in the order in which they were defined. Then the above declaration would just be an abbreviation, as before. A further note on else clauses: If you have user-controlled exceptions, one can use an else clause to raise an exception suitable to the particular test statement which fails to match. This can be more useful than raising a system exception. I know Bertrand has accepted Erland's arguments for an else clause; but I think this use for them is worth mentioning anyway. (The references I have on eiffel are strongly against exceptions, so I presume they're out of date! I'm currently trying to get hold of the eiffel book; I apologise if I've made any inaccurate assumptions in the above.) Dave Berry, Laboratory for Foundations of Computer Science, Edinburgh. db%lfcs.ed.ac.uk@nss.cs.ucl.ac.uk !mcvax!ukc!lfcs!db