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: Difference between these pointer syntaxes Date: Mon, 15 Aug 2016 17:57:26 -0700 Organization: None to speak of Lines: 94 Message-ID: References: <87tweqdeuo.fsf@bsb.me.uk> <87y441a697.fsf@bsb.me.uk> <87r39s8w6c.fsf@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="24848"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/+OW+iI1xqLyOpyWyEmKmZ" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:R9ozneEoJSHfChrdbMudUwKeNoY= sha1:mTXwVJ/Qnv8ntPi3d176u4Zq9h4= Xref: csiph.com comp.lang.c:92326 BartC writes: > On 16/08/2016 00:03, Keith Thompson wrote: >> BartC writes: >>> Yes. But >> [SNIP] >> >> You've said you find this very confusing. Taking you at your word, >> I'm beginning an attempt to explain it, starting with a simple and >> straightforward example. If you're going to immediately, after just >> one word of acknowledgement, into examples designed to confuse the >> issue, examples we've all seen before, this isn't going to work. >> >> Are you interested in learning how arrays work in C or not? > > I know how they work, more or less. No, you don't, not if you think arrays and pointers are the same thing. > But I don't think much of C's > array/pointer model, as you might have guessed. There are simpler > schemes of doing this at this level of language, ones which don't > require them to be so much entwined. (Some languages have arrays, but no > pointers, for example.) How is that relevant? As I've said before, I don't particularly *like* C's array-pointer model either. Whether you like the model or not, are you interested in understanding it? If so, are you willing to cooperate with me in explaining the model? That means not running off and introducing examples that you think prove that C's treatment of arrays and pointers sucks. It means trying to understand examples that I present on their own terms before moving on to the next step. > So you're not going to convince me that arrays and pointers in C have > hardly anything to do with each other. Good, because I've never said that. They have a lot to do with each other. What I've actually said is that they are not the same thing. > You gave me what you thought was a cast-iron example of an array > declaration, and I gave the exact same example back in a context where > it was a pointer! That's why I described the context in which the array definition occurs. We already know that the same syntax in a different context has a different meaning. I wasn't talking about that different context. If we try to cover everything simultaneously, we'll never get anywhere. > If you want an example of a language where these two type categories are > REALLY distinct, and strictly enforced, then I suggest one of mine (or > Pascal as something that can be looked up). But C isn't one of those. If we want to talk about some other language, we should do it elsewhere. I know Pascal reasonably well (at least one or two dialects of it), and I understand that it treats arrays and pointers differently than C does. If you want to say that Pascal is better than C in that area, I won't argue. That's not what this is about. > If I said that arrays and pointers in C are the same, then perhaps that > wasn't exactly right, Then we've made some progress ... > but within the context of that example, then yes > they were were treated interchangeably. ... but not much. Please stop moving the goalposts. Are you willing to work with me on this? Yes or no. If not, are you willing to acknowledge that YOU DON'T UNDERSTAND C ARRAYS AND POINTERS, and stop trying to teach others based on your misunderstandings? My goal here is that you will understand C's treatment arrays and pointers better than you currently seem to. I don't expect you to *like* that treatment, just understand that is C's type system, warts and all. Failing that, I'd like to persuade you to stop spreading confusion and misinformation, so that I don't need to spend my time correcting your misstatements. What do you say? -- 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"