Path: utzoo!attcan!uunet!samsung!munnari.oz.au!basser!ultima!potter From: potter@ultima.cs.uts.oz (John Potter) Newsgroups: comp.lang.eiffel Subject: Re: a < b < c Message-ID: <16655@ultima.cs.uts.oz> Date: 25 Nov 89 13:57:24 GMT Organization: Comp Sci, NSWIT, Australia Lines: 47 From article <192@eiffel.UUCP>, by bertrand@eiffel.UUCP (Bertrand Meyer): >From article <182@enea.se>, sommar@enea.se (Erland Sommarskog): > > > [...] The rule for a relational expression should be something like: > > Rel_exp ::= Expression (Rel_op Expression)* > > [...] The semantic interpretation would be than of a logical AND so > that: > > a < b <= c > a + 2 > > would be a shorthand for > > a < b AND b <= c AND c > a + 2 > > [...] Since Eiffel still is open for changes for some more time, > > why not take the chance and add it? Not an essential thing, > > but one of those little things that makes life easier. Or > > is there some problem I have overlooked? > > I have tried to find an argument for not following > Mr. Sommarskog's suggestion and I cannot think of one. > As a matter of fact, many assertions in the basic Data Structure > Library and elsewhere would be written more simply in this way. > > It may be that the reason why no mainstream language has > included the form suggested by Mr. Sommarskog is that people feared > ambiguity. > But the simple semantics he suggests (``and'') makes any such fear > unfounded. I've just got around to reading these articles and their followups. It may be of passing interest to note that the language Miranda allows precisely this form of relational expression. Miranda is a functional language with non-strict semantics (i.e. uses lazy evaluation). The semantic interpretation of a < b <= c > a + 2 would be akin to the Eiffel form a < b and then b <= c and then c > a + 2 The "then" corresponds to the non-strict semantics in Miranda. I don't wish to debate whether Miranda is a mainstream language or not, but it is attracting considerable interest as a vehicle for introductory programming courses (more or less in competition with Scheme). In our first year courses in Computer Science here at the University of Technology, Sydney, we are currently introducing our students to both Miranda and Eiffel. Miranda is taught as part of a Discrete Mathematics subject, and Eiffel within our programming subjects.