Proposal for `?` operator name

Following the previous evidence that rust loves sea creature (see Ferris the crab, and turbofish), we should continue this theme and name this operator with another of this kind. Afterall, we know that salty water makes metals rust faster (pun intended).

Squeel Operator

From squeal + eel. Here a picture to depict this operator

Eeel

  • It resembles question mark (see picture above), just like ::<> resembles fish
  • It's a sea creature. From wikipedia:

Most eels live in the shallow waters of the ocean and burrow into sand, mud, or amongst rocks.

  • Good at jumping around when you catch it, related to the early return behaviour of ? operator.
  • Squeal, verb, make a long, high-pitched cry or noise.. Related to the returning error behaviour, probably :stuck_out_tongue:
  • The operator itself makes your code look slick.

What do you think?

Edit: credit to the people at #rust-offtopic, this idea was taken from the discussion there

9 Likes

In my head I call it the “why?” operator.

3 Likes

I just call it the “try operator.”

19 Likes

Hook/lure operator.

Also interesting in such cases is official pronunciation. For inspiration, Victor Borge’s phonetic punctuation routine.

1 Like

You missed the very important fact that it has “que” in the middle :wink:

4 Likes

unwrap

That’s an eel made to represent a question mark. I would call it the throw operator personally, since it throws out errors from the execution flow.

What’s the value add?

It makes sense to give a name to ::<> since “colon colon less than greater than” is a mouthful. But in the case of ?, you’re not just proposing a name, you’re proposing to rename it. Why call it anything other than “question mark” or “question mark operator”?

9 Likes

Where is the catch?

Since panics are not exceptions, and ? does not throw or panic or call unwrap(), if we decide we want a name that describes what it does I think “early return” operator would be much better than “throw” or “unwrap” operator.

But overall I agree with @jimrybarski: There already is an obvious name of “question mark operator”, unlike with the turbofish, so we might as well stick with that.

1 Like

Anybody trying to push their own favorites, such as “try”, must address the point brought up by @jimrybarski

I like “try” better than “question mark” because it’s related to what the operator does, rather than what it looks like. Just like * is not called an asterisk operator, nor & an ampersand operator.

9 Likes

The Carrier documentation already refers to it as the question mark operator. It’s kinda like a panicless trow. “early return” is apt but it only as long as we don’t have the catch block. Sort of a “break on Err/error”

Yeah I see nothing wrong with “the question mark operator”. It’s not like “the double colon angle brackets operator” or Python’s “underscore underscore init underscore underscore” (which still doesn’t seem to have a good name). It’s pretty simple to say “the question mark operator”.

1 Like

I usually refer to __init__ as “constructor”.

I’m against QuestionMark for the operator name. It’s inconsistent with the names for other operators, e.g. Not,Add, Div instead of ExclamationMark, Plus, Minus. They all have been given names for their intended uses instead of the literal name of the symbol. Also if, in the future of Rust, we want to add another operator that also uses ? somehow in a different context, then the name “question mark” would carry meaning for two different operators.

Note that this is already the case: * is both used for Mul and Deref, - is both used for Sub and Neg.

Seeing as ? replaces the try! macro, Try seems to me a sensible choice. Or at the very least, some name that makes its intended use obvious.

7 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.