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 10:03:11 -0700 Organization: None to speak of Lines: 73 Message-ID: References: <8737mdh47k.fsf@bsb.me.uk> <87mvkkflc0.fsf@bsb.me.uk> <871t1wf8f8.fsf@bsb.me.uk> <87vaz7eg7c.fsf@bsb.me.uk> <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="24188"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18SJkF3tQsc69XrpytG5Soh" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:HkwRicXuAlA7XTlr9Tuz1MpGZ6c= sha1:gEXvZ2o4hBHGyiwFjGOq2c+0Mkw= Xref: csiph.com comp.lang.c:92297 BartC writes: > On 13/08/2016 18:35, BartC wrote: >> On 13/08/2016 17:34, Ben Bacarisse wrote: >>> This is the trouble with the salad bar method of language design. It's >>> not wise to pick and choose features arbitrarily. A design relies on >>> many decisions fitting together together to make a coherent whole. C's >>> arrays and pointers are, in my view, coherent, despite being very >>> different to those in other languages. >> >> Coherent is not what I'd call it. There are enough inconsistencies that >> it would make a sizeable list. (Perhaps I might do that, although it >> won't be as many as 100 like the list of things that I also don't like; >> this would be more objective.) > > > I've put together my new collection of C quirks here: > > https://github.com/bartg/langs/blob/master/C%20Quirks.md I reviewed a similar list of yours a while ago via e-mail. It appears that I wasted my time. I just took a quick look at this new list. Your decision to invent new notation (like "ref" for pointers and "[10]int" for int[10]) is ... well, not a choice I would have made. If you want to avoid C's admittedly confusing declaration syntax while discussing C's semantics, I suggest using English ("pointer to int", "array of 10 int"). The cdecl program is very helpful for this kind of thing. You have a section titled "Value arrays". Do you think there's a distinction between "value arrays" and some other kind of arrays? There isn't. Among other things, I suggest the discussion would be a lot clearer if you'd use the word "array" as an adjective, not as a noun, and distinguish clearly among array types, array objects, array expressions, and array values. Your discussion of the contexts in which an array expression does or does not decay to a pointer is far less coherent than it needs to be. Your description seems to be deliberately confusing, and in the last paragraph you appear to *guess* about the actual rules -- which are really fairly simple and have been explained to you multiple times. (Your guess is wrong, by the way; there is no exception for the LHS of an assignment. An array on the LHS of an assignment is a constraint violation, so the conversion rules do not even apply.) I haven't read the rest of it, except for the title of another section: Arrays and pointers are the same No, they are not. This is one of the most common and harmful misconceptions about C. *Please please* stop propagating it. > (Also, how those quirks are handled in my own language: > > https://github.com/bartg/langs/blob/master/C%20Quirks%20in%20M.md > > As I believe that someone making such implied criticisms should be able > to demonstrate a viable alternative.) (I saw no *implied* criticisms; you were quite explicit.) If you're going to criticize C (and there's plenty to criticize), it's not *really* necessary to invent a new language as an alternative, but I applaud you for doing so. But you must understand C itself. Your list, or at least the initial part that I read, indicates that you do not. -- 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"