Path: csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.lang.c Subject: Re: arranging items in a array with a sorted pointer-list Date: Sun, 13 Dec 2020 11:06:56 -0800 Organization: A noiseless patient Spider Lines: 94 Message-ID: <86v9d5zfsf.fsf@linuxsc.com> References: <87wny3yp2n.fsf@bsb.me.uk> <20201130124004.239@kylheku.com> <%6dxH.49582$kM7.20584@fx43.iad> <20201130142116.891@kylheku.com> <1by2ii72fj.fsf@pfeifferfamily.net> <20201130174257.91@kylheku.com> <86y2ihoijs.fsf@linuxsc.com> <871rg9o0x3.fsf@nosuchdomain.example.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="b9b2ee0d4c4a5c7f42f81fa91d7a0e4d"; logging-data="27531"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/sy06EaEWD0HpUcEZCET4omkTBCHU+DkY=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:KwgLuOlJmHNzXGMj7b91mK0yRVU= sha1:L8K71W8EYrnC3feU3nHp0HjMS84= Xref: csiph.com comp.lang.c:157254 Keith Thompson writes: > Tim Rentsch writes: > >> Kaz Kylheku <563-365-8930@kylheku.com> writes: >> >>> On 2020-12-01, Joe Pfeiffer wrote: >>> >>>> Kaz Kylheku <563-365-8930@kylheku.com> writes: >>>> >>>>> It can be the case that at the time the cast is written, there is no >>>>> const qualifier being cast away. The accident occurs when someone >>>>> later introduces const, and that cast now silently subverts it. >>>> >>>> Raising a question -- what would have been the downside (note that I'm >>>> recognizing it's Too Late, just Monday morning quarterbacking), when >>>> const was added to the language, to defining the cast so it doesn't >>>> throw the const away? > > [...] > >>> I think that it would be a good choice for C++ or a C dialect >>> inspired by C++, in which there are overloaded functions and other >>> features. >>> >>> jhere is the problem that the current function >>> >>> char *strchr(const char *str, int ch); >>> >>> could not be written in that dialect. [...] >> >> Think again. Yes it could. > > You have a habit of (it seems) deliberately withholding information > by alluding to some idea and expecting others to do the research > to reinforce your conclusions. I find it annoying. Does anyone > else find it at all useful? There are a lot of different factors that go into deciding what to say when I post. Let me go through some recent examples. In a thread about how to rearrange elements of an array, I posted that I had a short function to do it but did not post the function. Because no algorithm had been posted, someone else following up to my posting thought about the problem and posted a solution that was a nice improvement over my own. In a thread about changing the semantics of pointer casts so 'const' would be preserved, I posted a comment about several points, but notably including a statement about being able to provide a const-preserving cast using _Generic. My post included a short example of how to do that. In this very thread, I implied that a const-removing conversion could be accomplished but didn't say how. Discussion following that comment turned up several different was of thinking about how a const-removing conversion might be effect, including a very nice technique from Ben Bacarisse. Of course I don't know for sure but I suspect the discussion would not have been as diverse if I had simply stated one way right at the outset. In each of those cases I'm happy with the outcome, and I think other people reading the thread probably benefited from my choice, even if the OP being responded to didn't feel that way. Those sorts of considerations aren't always obvious. Note also that not providing information is not the same as withholding it - I might choose not to say much at the start of a conversation and then say more later, depending on which way the discussion goes. Let me ask you about a case that has come up just today. Looking over the programs posted to solve the decommenting exercise, there was one that showed surprising behavior, and I ended up tracking down several defects in the code. Now having this information, what should I do about it? Should I * post nothing at all? * post a statement saying the code has problems but not say anything about what the problems are? * show some test cases that evoke bad output? * identify a particular function where the problems are but not say any more than that? * say what the problems are but not more than that? * post revised code that fixes the problems? It isn't obvious to me which of these choices (and the list is not exhaustive) is the best choice overall for all concerned, including readers other than the poster whose code is involved. I think different people would prefer different choices. What's a good choice for what to do here? I'm interested to hear your assessment.