From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1d321b3a6b8bcab2 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1995-01-14 02:37:11 PST Newsgroups: comp.lang.ada Path: nntp.gmd.de!newsserver.jvnc.net!news.cac.psu.edu!news.pop.psu.edu!hudson.lm.com!netline-fddi.jpl.nasa.gov!elroy.jpl.nasa.gov!swrinde!gatech!udel!news.sprintlink.net!pipex!uunet!telesoft!kst From: kst@alsys.com (Keith Thompson) Subject: Re: "Subtract C, add Ada" Message-ID: Originator: kst@pulsar Sender: news@alsys.com (USENET News Admin @flash) Organization: Alsys, San Diego, CA, USA References: <3etund$hnr@miranda.gmrc.gecm.com> <3f4mbe$rud@cronkite.seas.gwu.edu> Date: Sat, 14 Jan 1995 10:37:11 GMT Date: 1995-01-14T10:37:11+00:00 List-Id: In <3f4mbe$rud@cronkite.seas.gwu.edu> dobrien@seas.gwu.edu (David O'Brien) writes: > I have to wonder. What if C defined the logical equals operator to be > "=" and the assignment operator to be ":=" just like Ada, Algol, Pascal, > Modula-x, etc? Would this error still exist??? > > Quickly thinking about it, I feel that I write a lot more assignment > statements than local statements, couldn't I be in the habit of typing > ":=" and thus accidently type that when I meant logical comparison? > Since that would still be a perfectly valid, conforming C program, > the compiler is not required to give any warnings (just like current > practice). Thus, I would still have the same logic error in my program. > Chances of happening??? Any bodies guess. So is the problem really > one of symbol choice, or program semantics? I suspect this error would be rarer if C used ":=" for assignment. The symbol "=" is used for equality in some languages (Pascal, standard mathethematical notation, etc.) and assignment in others (Fortran, C, etc.). The symbol ":=" is used only for assignment. I don't think I've ever accidentally typed ":=" for a comparison in Ada. Digression: I once heard about a relatively obscure language that used ":" as a catenation operator. It also had C-style assignment operators. So, naturally, the statement "x := y;" assigned to x the result of catenating x and y. end Digression; Of course, if C used ":=" for assignment and "=" for comparison, the opposite error would be likely to occur; people would commonly type x = y; which, instead of assigning the value of y to x, would compare them and discard the result. This could be caught by a compiler warning; an assignment in an expression context sometimes makes sense, but a comparison in a statement context never does. It could even be forbidden, but I suppose that would violate the spirit of C. Hmm. How about ":=" and ".EQ."? 8-)} Please note that this article is not an anti-C flame; it's a theoretical discussion about programming language syntax design. Yeah, there's the ticket. -- Keith Thompson (The_Other_Keith) kst@thomsoft.com (kst@alsys.com still works) TeleSoft^H^H^H^H^H^H^H^H Alsys^H^H^H^H^H Thomson Software Products 10251 Vista Sorrento Parkway, Suite 300, San Diego, CA, USA, 92121-2718 When you're a nail, every problem looks like a hammer.