Path: utzoo!attcan!uunet!mcvax!kth!sunic!enea!sommar From: sommar@enea.se (Erland Sommarskog) Newsgroups: comp.lang.misc Subject: Re: What I'd really like to see in an if-statement... Message-ID: <178@enea.se> Date: 11 Aug 89 23:29:15 GMT Organization: Enea Data AB, Sweden Lines: 25 I think John Lacey (lacey@tcgould.tn.cornell.edu) said this: >The parse would be more difficult. The problems aren't analogous. The >dangling-else problem is one of ambiguity. Parsing a general relational >expression is difficult because the same string will be used for multiple >tokens. For example, in (a < x < b), x has to be associated separately >to its left and right. I have to object here. Way back at the university I took a compiler course. In the tiny language I made for my assignment I defined the grammar relational expression something like: rel_exp ::= exp (rel_op exp)* ()* meaning 1 or more times easy. Trivial, isn't it? The semantic interpretation was AND. I.e. 0 < x < 10 was interpreted as (0 < x) AND (x < 10), which seems as the natural interpretation for the case you would like to use it for. A thing like a = b <= z > y < b wouldn't something to recommend but the langauge dealt with it the same way. Actually I have always been surprised that no language I have dealt have had this feature since it is so easy to implement. Am I overlook- ing something? -- Erland Sommarskog - ENEA Data, Stockholm - sommar@enea.se "Hey poor, you don't have to be Jesus!" - Front 242