Path: csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: My C program does not compile or gives segmentation fault Date: Mon, 27 Mar 2017 09:36:45 -0700 Organization: None to speak of Lines: 36 Message-ID: References: <89549322-236e-4a59-9bb5-dc881593a846@googlegroups.com> <1b709495-03da-462d-926f-3ee2be0a7ab5@googlegroups.com> <58d642e0.2297265@news.xs4all.nl> <58d6e0b3.20124312@news.xs4all.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="bc4ad8e6098eee52cc8cf8ccb2486caf"; logging-data="2925"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18NX8QmwB+MGQETNYRJPj6x" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:ccNcS8OjGd1/+kPNyMKOHjAcf9I= sha1:WQQCVtSGE121fOZzrRBCaWwuA5k= Xref: csiph.com comp.lang.c:107172 BartC writes: > On 27/03/2017 16:49, Keith Thompson wrote: >> And if C had chosen assignment and equality operators that aren't >> so easy to mix up (say, := for assignment and == for equality), >> I don't think anybody would ever consider writing `if (3 == x)`. > > #define EQ == > > if (x EQ 3) .... I prefer not to use the preprocessor to change the language syntax. Personally, I find (x EQ 3) worse than (3 == x). > > (say, := for assignment and == for equality), > > If := meant assignment, why wouldn't you use = for equality? You just > need to make it an error to write: > > x = y; > > for those mistakenly using = in place of := I think you just answered your own question. "=" is commonly used either for assignment or for equality. ":=" is rarely used for anything other than assignment. "==" is rarely used for anything other than equality. I used "==" to avoid ambiguity in the current discussion. I have no problem with a language using ":=" for assignment and "=" for equality (as Pascal and Ada do, for example), but "==" makes for clearer examples here. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"