gvcormack@watdaisy.UUCP (Gordon V. Cormack) (10/17/86)
There has been discussion in the net on languages that allow the notation x < y < z as a shorthand for x < y and y < z With user-defined types and overloaded operators (like in Ada) this is easy to set up (I will spare you the tedious Ada Syntax). type tempresult = record val: real tst: bool end operator "<" (a: real, b: real) bool = ... the normal comparison operator "<" (a: real, b: real) tempresult = (val => b, tst => a < b) operator "<" (a: tempresult, b: real) bool = (a.tst and a.val < b) operator "<" (a: tempresult, b: real) tempresult = (val => b, tst => a.tst and a.val < b) Aren't data types wonderful? -- Gordon V. Cormack CS Department, University of Waterloo gvcormack@watdaisy.uucp gvcormack%watdaisy@waterloo.csnet
brad@looking.UUCP (Brad Templeton) (10/18/86)
In article <7934@watdaisy.UUCP> gvcormack@watdaisy.UUCP (Gordon V. Cormack) writes: >There has been discussion in the net on languages that allow the >notation x < y < z >as a shorthand for x < y and y < z > >With user-defined types and overloaded operators (like in Ada) >this is easy to set up (I will spare you the tedious Ada Syntax). > >Aren't data types wonderful? >-- >Gordon V. Cormack CS Department, University of Waterloo Sure, but I have been wondering what all the fuss is. x < y < z is not all that exciting, and not much shorter than what it is supposed to shorten. Certainly I don't see compilers generating better code from it. There are lots of valuable things you can do with more general languages, but I don't think this is one of them. I can't imagine a language designer deliberately complicating things just to support this one. -- Brad Templeton, Looking Glass Software Ltd. - Waterloo, Ontario 519/884-7473
garry@batcomputer.UUCP (10/24/86)
In a recent article brad@looking.UUCP (Brad Templeton) wrote: >Sure, but I have been wondering what all the fuss is. x < y < z >is not all that exciting, and not much shorter than what it is >supposed to shorten. Certainly I don't see compilers generating >better code from it. > Think back many many years ago to CS 101 and the first time you had to test whether a number was between two other numbers: how did you instantly and naturally write it down ? And what did the compiler say? >There are lots of valuable things you can do with more general >languages, but I don't think this is one of them. I can't imagine >a language designer deliberately complicating things just to support >this one. > "Valuable" includes "more understandable", not just "more powerful" :-) garry wiegand (garry%cadif-oak@cu-arpa.cs.cornell.edu)