Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: C++ features for C Date: Sat, 12 May 2018 15:53:34 -0700 Organization: None to speak of Lines: 44 Message-ID: References: <11edbfd7-461d-4579-8ac7-a9e84a6b7630@googlegroups.com> <7b110d3e-ddb5-42a0-af99-aa5b0cb30832@googlegroups.com> <13efc313-d10c-4357-9aa7-6fa55b09d948@googlegroups.com> <6jJJC.146191$MD7.27173@fx14.am4> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="b241fefa6b912bdefe83ae72b0e16b14"; logging-data="11586"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+QGAOY0OSyZNg9nw6xZ9Ut" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:6nNt4Lqefbh8oZKqi39dWVqU9io= sha1:yjbRU3lL8vsLAp8Cmafj33FVe8o= Xref: csiph.com comp.lang.c:130477 bartc writes: [...] > & works with a normal variable, because when you write: > > double x; > > then the type of 'x' - the name, not the contents of the location it > refers to - is really double*. When used in an expression, it is > automatically dereferenced to yield the contents of the location: > > *(&x); // equivalent to just x in a HLL > > When you write &x, then that is really this: > > &*(&x); > > The & and * cancel to leave you with &x, of type double*. "That's not how this works. That's not how any of this works." The object named `x` is of type double. The definition `double x;` does not create anything of type `double*`, any more than it creates anything of type `size_t`. The *expression* `&x` is of type `double*`. That value, of pointer type, doesn't exist until the expression `&x` is evaluated. Similarly, `sizeof x` is of type size_t, and that value doesn't exist until the expression `sizeof x` is evaluated. An lvalue is an expression that "designates" an object. That is not at all the same thing as a *pointer* to an object. [...] > This why I think few people 'get it'; they certainly don't get the need > for an ultra-simple feature with straightforward rules. You should understand the existing rules before proposing new ones. -- 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"