-11

In response to C ternary operator, can I omit one part?, my answer has been deleted by a moderator as being "code golf" and unhelpful.

The OP asked if C allowed circumventing (omitting part of) the syntax of an expression. My answer showed a working alternative (using a "functional" technique.)

EDIT: "branchless", no "functional".

Is there a guideline as to how far is too far when answering SO questions?

Must all answers provided remain rigidly "inside the box?"

12
  • 7
    Rigidly? No, not at all. But your answer really doesn't address the question. It only works on mathematical operations where you can produce an identity in some cases, it's barely readable, and is overall a totally impractical "solution" to the general case of replicating one half of the ternary operator without an inline if statement. It's a trick that only works because of the particular toy examples the question chose.
    – Ryan M Mod
    Commented Sep 7, 2022 at 2:01
  • @RyanM "produce an identity"... The OP's "absent" clause IS an implied "identity" operation. "barely readable" ... Upskilling might help there. "the general case..." Re-writing/re-framing the OP to fit inside your worldview? "without an inline if statement"... Where is the "if()" in my proposed answer?
    – Fe2O3
    Commented Sep 7, 2022 at 2:05
  • 2
    "Re-writing the OP to fit inside your worldview?" I quote: "I wanted to know if there's a way to omit second or third part of the ternary operator" - I see nothing saying that they care only about mathematical operations. if(x == y) do_something; is also not specific to mathematical operations.
    – Ryan M Mod
    Commented Sep 7, 2022 at 2:08
  • 1
    @RyanM The other "answer" (currently with 2UV's) completely departs from the "trenary operation"... Why, as my question here asks, has that other answer not been deleted based on its "unrelated-ness" to the question about omitting "second or third part of the ternary operator"? No "ternary operator" in that "answer"... Even handed (I ask again)? Again, referring to the OP, do_something has been given ONLY as mathematical operations... Who decides that do_something means a broader range of possibilities??
    – Fe2O3
    Commented Sep 7, 2022 at 2:12
  • @RyanM -- I agree that the answer had problems, but I can see how summary deletion by a mod could seem somewhat arbitrary in this case. I suspect that if someone had flagged the answer as NAA, that flag would have been declined; some comparison of criteria for deletion vs criteria for NAA may be helpful. I may be wrong about this, though, since NAA flags seem slippery. Commented Sep 7, 2022 at 2:25
  • 2
    @adabsurdum I concur that a plain NAA flag would have been likely to be declined, though moderators have a bit of leeway in deleting answers on their own initiative for reasons outside of the standard NAA reasons (similar to 20k users and the delete-vote privilege). I don't know if I personally would have deleted this (it certainly would merit a downvote, for the reasons I discuss above), though I understand why the other moderator did so.
    – Ryan M Mod
    Commented Sep 7, 2022 at 2:29
  • "The OP asked if C allowed circumventing (omitting part of) the syntax of an expression. My answer showed a working alternative (using a "functional" technique.)" The question is whether it's possible to use part, and only part of a specific construct. An answer that doesn't use the construct at all is not addressing that question. Similarly, showing code using ?: would not answer a question about whether an else block is necessary after if. (It doesn't actually matter, in this analysis, whether the answer to the original question is "yes" or "no".) Commented Sep 7, 2022 at 2:35
  • @RyanM Again I ask why the 2UV answer has not been deleted as its "solution" departs from using the "?:" expression... On what grounds is that 'answer' considered to be "AA" to the OP?? I could write a for( ) expression that would not be "if( )` yet would do_something only once under a given condition... Who minds the minders? And, why is "thinking outside the box" penalised on SO?
    – Fe2O3
    Commented Sep 7, 2022 at 2:35
  • @KarlKnechtel " An answer that doesn't use the construct at all is not addressing that question." So WHY is the other answer UV'd while my original answer is deleted by a "moderator"? Moderation shouldn't be immoderate, imho...
    – Fe2O3
    Commented Sep 7, 2022 at 2:38
  • Why is it upvoted: because at least it handles the general case rather than hiding it behind tricky math that, to quote the moderator who deleted your answer, only works for one of their cases. It's also not functional programming, by the way, but that's not actually relevant to this.
    – Ryan M Mod
    Commented Sep 7, 2022 at 2:41
  • Are both answers necessary now that the original has been undeleted?
    – Henry Ecker Mod
    Commented Sep 7, 2022 at 4:18
  • @HenryEcker They are two different answers. One trivially provides the "no-op" value that satisfies using the trenary operator (one of the OP questions). The other starts off explaining "trenary means 3", but answers the other OP question: "What else could I do"... People can read (or not) whichever one they choose.
    – Fe2O3
    Commented Sep 7, 2022 at 4:22

2 Answers 2

-1

I took the answer in dispute to be indirect at best with respect to the first part of the question (does the ternary operator require all three operands), but it was indeed to responsive to the second part (what else can I use besides an if statement). That it was limited in scope with respect to that part was in no way reason for deletion.

@user229044 seems to have taken the answer to be unhelpful, and that's fine, but the right response to that under the circumstances would have been to downvote. Deleting the answer at their own initiative was an abuse of moderator abilities.

1
  • We all have "good days and bad days"... "All's well that ends well" -- William S. :-)
    – Fe2O3
    Commented Sep 7, 2022 at 20:32
11

This has nothing to do with "out of the box" answers. I deleted your answer because I didn't think it was a good-faith attempt to provide a serious, helpful answer to the question. I read it as a slightly sarcastic joke response.

Here's why:

  • You have a single English sentence that serves no purpose but to support a pun; it offers no explanation for the solution you're proposing
  • You include a bunch of non-obvious code that is of very little help to a novice C programmer
  • Your code only works on one specific case given by OP, not in the general case
  • Your code contains a single comment that I interpret as sarcastic: No "?:" in sight!! - this was never a stated goal of OP, and simply avoiding ?: is trivially done any number of ways; in fact, ?: was never necessary or appropriate here in the first place, so removing it is hardly novel
  • If your answer is on-topic, then an arbitrary number of silly answers are also on-topic, for example while (x == y) x *= 2; is on-topic.

In all, I read your answer as a joke, riffing on the OP's (IMO) misguided requirement to avoid the simple if statement that is the obvious answer to their problem. If you wanted to offer a semi-serious suggestion that only partially addressed the question, a comment would have sufficed.

You have also repeatedly argued that another answer was unjustly left alone; the fundamental difference is I believed that answer was a good faith attempt to help OP, and by the time I had seen that answer it had also been edited to explicitly and directly answer the question (offering a GCC flag to do exactly what OP had asked about).

8
  • "...the OP's (IMO) misguided..." That is the very foundation of any "question" that seeks an answer. "an arbitrary number of ... answers are also on-topic" If they provide fodder for thought (by novices or experts) that is called "thinking outside the box", the title of this post... And, in conclusion, I apologise for trying to be light-hearted in these days of unabating doom and gloom.
    – Fe2O3
    Commented Sep 7, 2022 at 3:18
  • 1
    @Fe2O3 If you truly believe your answer has merit and wasn't just a joke (I presume you do, given this meta question), I will undelete it, but I would hope you will at least edit in an explanation of how it works and what its advantages and disadvantages are vs the obvious solution.
    – user229044 Mod
    Commented Sep 7, 2022 at 3:26
  • 2
    In lieu of the "constructive criticism" (not) offered a few hours ago, I would appreciate the opportunity to "improve" that answer. :-)
    – Fe2O3
    Commented Sep 7, 2022 at 3:28
  • 1
    Posted edit. Thank you for the (somewhat circuitous) opportunity to improve my answer.
    – Fe2O3
    Commented Sep 7, 2022 at 4:12
  • 3
    @Fe2O3 generally, we hate fun on SE ;)
    – Andrew T.
    Commented Sep 7, 2022 at 4:52
  • You always have the opportunity to edit an answer, even if it's been deleted. In fact, that's kinda the whole point of deletion: hiding it until you get a chance to edit it and bring it up to standards. @Fe2O3
    – Cody Gray Mod
    Commented Sep 7, 2022 at 7:31
  • 1
    Why do you now have two answers? Posting two answers to the same question is almost always inappropriate. You should combine them and delete one.
    – Cody Gray Mod
    Commented Sep 7, 2022 at 7:32
  • @CodyGray Re: "edit deleted answer": Coulda sworn edit of my post deleted by moderator was unavailable to me, but I was somewhat upset at that time. If it happens again, I will remember your 'tip'. Thank you... Re: "two answers": When the first was deleted as "silly", I restated my comment under the OP as a full-blown "answer". (OP person had thanked me(!) in a comment. Wow!) Other (edited) answer responds to other OP question (roughly) "What else can I do..?" Merging them would, I think, be mixing apples & oranges. (Double the opportunity for DVs. Coming to expect those from SO old-timers.)
    – Fe2O3
    Commented Sep 7, 2022 at 7:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .