Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Using == operator Date: Tue, 03 Jan 2017 15:30:43 -0800 Organization: None to speak of Lines: 29 Message-ID: References: <4598b1a6-e647-4327-85d8-23f83198d0c6@googlegroups.com> <640f8d29-0683-4614-9cde-c22e80e4dd00@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="167f7d05f22907ea8e3985ed50c4ed73"; logging-data="9414"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX186iQUhMWVyaB25h0Whg77T" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:GC2J+yEVKBhJnKSfHUXYFeoCmzM= sha1:Zvj/RpwgeOu/AgyX2/n0arLwFPo= Xref: csiph.com comp.lang.c:101056 supercat@casperkitty.com writes: > On Tuesday, January 3, 2017 at 4:06:27 PM UTC-6, Keith Thompson wrote: >> Even if we assume that that corresponds to `if (apple_count)`, what's >> the corresponding English for if(node->next)? > > Since every pointer which is used in such a context is required to either > be a valid pointer or a null pointer, the English would be "If the object > pointed to by 'node' has a valid 'next' pointer, then...." Although the > code is in a literal sense comparing a pointer with a null pointer, such > a comparison is merely the means by which code determines that a pointer is > valid. A null pointer is valid in some contexts (including this one), there are invalid pointers other than the null pointer, and claiming that if(node->next) can be read as If the object pointed to by 'node' has a valid 'next' pointer, then.... hardly supports the claim that it "reads like English". -- 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"