Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!kddlab!titcca!sragwa!wsgw!socslgw!diamond!diamond From: diamond@diamond.csl.sony.junet (Norman Diamond) Newsgroups: comp.lang.pascal Subject: Re: C Ternary Conditional Expression? Message-ID: <10296@socslgw.csl.sony.JUNET> Date: 29 May 89 03:59:40 GMT References: <950025@hpclcdb.HP.COM> <6490002@hplsla.HP.COM> Sender: news@csl.sony.JUNET Reply-To: diamond@csl.sony.junet (Norman Diamond) Organization: Sony Computer Science Laboratory Inc., Tokyo, Japan Lines: 54 In article <6490002@hplsla.HP.COM> davidr@hplsla.HP.COM (David M. Reed) writes: >However, C programmers have continually reminded me how "efficient" >code can be written in C verses Pascal, such as > a[ (indx == last_indx) ? last_val : f(indx) ] = a [ y ]; >instead of > > IF (indx = last_indx) > THEN temp := last_val > ELSE temp := f(indx); > a[temp] := a[y]; Actually the same could be done in Algol. It is strange that C copied that construct when no other language has done so. Anyway it is ugly and obfuscated. >So why write in the terse C format? I personally think that > loop = loop + 1; >is more clear than > loop += 1; I don't like the = forms because it's too easy to miss the when reading, but it really has an advantage when "loop" is really a big long hairy expression. >or the horrendous > loop++; This is not so horrendous. It is not too easy to miss "++". In fact, Brinch Hansen and other designers of Pascal dialects included generic INC and DEC procedure calls to do such operations. >And I despise things like > > y = ++x; Now we agree. This manner of hiding side-effects is also ugly and obfuscated. Worst is: if (a=b) This assigns b to a quite legally, and tests that value for non-zero, but doesn't compare a to b. Yup, C's philosophy is that programmers know what they're doing, and that C programmers know every time they've just made a typo, and that C programmers know they've forgotten every other programming language they've ever used.... -- Norman Diamond, Sony Computer Science Lab (diamond%csl.sony.co.jp@relay.cs.net) The above opinions are my own. | Why are programmers criticized for If they're also your opinions, | re-implementing the wheel, when car you're infringing my copyright. | manufacturers are praised for it?