30

Well-intentioned people tend to ask the same question over and over again: What does this mean:

var foo = bar ? 1 : 0;

It's the thing which most people (notably: most people on SO) call "the ternary operator," but strictly speaking is a conditional operator, but since the person asking generally doesn't know the name and it's not search-engine-friendly, they don't figure out how to find the existing questions, of which there are lots.

So my question is, how could we fix this? Is there a way to help people find results for syntax when they don't know the name?

Perhaps:

  • A grammar-and-language-aware question parser?
  • A language syntax reference which correlates to the correct SO tags?
  • Something else?

Nitpicker's corner: Added digression about common usage being incorrect. I think it's missing the point, but perhaps if I spell this out we can talk about the question I'm asking instead.

14
9

Maybe it would make sense if the FAQ pointed to a list of the most Frequently Asked Questions on the site, in addition to questions about the site.

4
5

Your point is valid, but I think this occurs infrequently enough that the existing vote-to-close mechanism is sufficient. Developing a more complex search would probably not be worth the effort.

1
  • 5
    Well, yes and no. Someday (when all the little problems are sorted out...) the team might start thing about making the search "better", and when they do this should go into the pot for consideration. May 6 '10 at 18:00
2

Why not have an option in the SO search to disable "assumptions" this when checked would allow you to search for what is ? operator and the ? character be weighted in the result.

2
  • 1
    I think that would be a great feature, though I think people might not use it since they would presume it does not exist. Having the automatic search on the title (when you post a question) use such a feature would be good. However, the most popular title for "?" questions is "What does this do"! May 6 '10 at 18:10
  • Yea, I'd say if we could have some sorta autodetection then that'd be great
    – Earlz
    May 6 '10 at 23:48
1

It's the ternary operator

Points for irony. You were joking there yes? Please?

Or as it should be:

It's the ternary conditional operator (which happens to be the only common ternary operator)

7
  • 10
    If there was a unicorn... And only one unicorn... and that unicorn happened to be a plumber named Bob... Then he would probably still be referred to as "The Unicorn" rather than "Bob the plumber".
    – Shog9
    May 6 '10 at 18:56
  • 2
    @Shog9 - the "only" is the problem. There is no guarantee that there will never be another ternary operator. I'm half tempted to invent a language with gluts of them, just to put this matter to rest. May 6 '10 at 19:10
  • No irony. And yes, I know what it's called. Even people who didn't would have learned it from reading the questions which caused me to ask this in the first place. But this question is about searching for duplicate answers, and there are twice as many pages in SO with ternary operator as conditional operator . Let's not miss the point here: "How do we steer folks asking questions about ? to the existing answers on the topic?" May 6 '10 at 19:10
  • 3
    @Carig - Eric Lippert puts it better than I can, on blogs.msdn.com/ericlippert/archive/2010/02/18/… - The trouble with "the ternary operator" is that it describes what it looks like, not what it does. This is why . + => are called the "member access operator", "addition operator" and "lambda operator" and not the "dot operator", "plus operator" and "fat arrow operator". May 6 '10 at 19:12
  • I'm not attempting to say that common usage is correct. I just want to avoid duplicates and get the folks asking these questions their answers faster. May 6 '10 at 19:18
  • 3
    @Marc: You should totally do that. And call it, "C?:"...
    – Shog9
    May 6 '10 at 19:23
  • @Marc Gravell: actually, I've found that for the purpose of communication, it is often better to call + . => as plus, dot, and fat arrow respectively. In the programming class I'm in, when I said "x assigned with a added by b", people hesitate a bit before understanding what I meant, that doesn't happen if I said "x equals a plus b". Most people have better association with the symbols than the operations themselves. It seems many people mentally translate the name of the operation into symbols in their head, so it's clearer to use symbol's name to skip the translation.
    – Lie Ryan
    Oct 15 '10 at 4:05
1

A Modest Proposal—a new ternary operator

I'd like to propose a new ternary operator to join the poor lonely conditional operator: the FMA operator. (Officially, it stands for fused multiply-add. Unofficially, it's like FML but with the obvious substitution. :-P)

Syntax:

expr * expr + expr

The point of this operator is, of course, that FMA will be seeing direct processor support soon. A useful secondary effect of this operator is that people have to be clearer about which ternary operator they're referring to. :-)

2
0

There's a "faq" tab for each tag that sorts questions by how frequently they're asked, based on links between questions and the like.

0

I'm more for the creation of tags for special characters, like [tag:?] (aaah... you can't do it... The tag formatter is intelligent enough to ignore the special characters. Let's say ). You could have 10/20 of these "special" tags, one for each common "symbol" (for example there are many question about the @ c# verbatim literal). The search engine could then try to match special characters to these tags quite quickly (perhaps simply looking if in a query there is an "isolated" symbol. So if you search for Can you help me? The ? wouldn't be matched. But if you searched for What does ? means it would) Persons that "know" with enough rep could then retag some good Q/A on the site with these tags and the tags of the correct language.

0

While Google can't handle symbols, SymbolHound can:

http://symbolhound.com/?q=%3F+c gives Statement with ? in C as its third hit.

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