# Proposal for \`?\` operator name

**URL:** <https://internals.rust-lang.org/t/proposal-for-operator-name/4531>\
**Category:** documentation\
**Created:** [December 30, 2016, 12:18am UTC](https://internals.rust-lang.org/t/proposal-for-operator-name/4531 "2016-12-30T00:18:10Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![matematikaadit](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/matematikaadit/32/2028_2.png) [@matematikaadit](https://internals.rust-lang.org/u/matematikaadit)\
**Post date:** [December 30, 2016, 12:18am UTC](https://internals.rust-lang.org/t/proposal-for-operator-name/4531/1 "2016-12-30T00:18:10Z")

</div>

Following the previous evidence that rust loves sea creature (see [Ferris the crab](http://www.rustacean.net/), and [turbofish](https://twitter.com/steveklabnik/status/659034597062262784)), 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](http://i.imgur.com/RC4kzvv.gif)

- It resembles question mark (see picture above), just like `::<>` resembles fish
- It's a sea creature. From [wikipedia](https://en.wikipedia.org/wiki/Eel):

> 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 😛
- 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

---

<div class="post-metadata">

**Author:** ![nnethercote](https://avatars.discourse-cdn.com/v4/letter/n/dfb087/32.png) [@nnethercote](https://internals.rust-lang.org/u/nnethercote)\
**Post date:** [December 30, 2016, 1:35am UTC](https://internals.rust-lang.org/t/proposal-for-operator-name/4531/2 "2016-12-30T01:35:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![notriddle](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/notriddle/32/14082_2.png) [@notriddle](https://internals.rust-lang.org/u/notriddle)\
**Post date:** [December 30, 2016, 2:02am UTC](https://internals.rust-lang.org/t/proposal-for-operator-name/4531/3 "2016-12-30T02:02:44Z")

</div>

I just call it the “try operator.”

---

<div class="post-metadata">

**Author:** ![hroi](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/hroi/32/1051_2.png) [@hroi](https://internals.rust-lang.org/u/hroi)\
**Post date:** [December 30, 2016, 2:27am UTC](https://internals.rust-lang.org/t/proposal-for-operator-name/4531/4 "2016-12-30T02:27:09Z")

</div>

Hook/lure operator.

---

<div class="post-metadata">

**Author:** ![chris-morgan](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/chris-morgan/32/9077_2.png) [@chris-morgan](https://internals.rust-lang.org/u/chris-morgan)\
**Post date:** [December 30, 2016, 2:50am UTC](https://internals.rust-lang.org/t/proposal-for-operator-name/4531/5 "2016-12-30T02:50:30Z")

</div>

Also interesting in such cases is official _pronunciation_. For inspiration, [Victor Borge’s phonetic punctuation routine](http://www.youtube.com/watch?v=Qf_TDuhk3No).

---

<div class="post-metadata">

**Author:** ![Diggsey](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/diggsey/32/6311_2.png) [@Diggsey](https://internals.rust-lang.org/u/Diggsey)\
**Post date:** [December 30, 2016, 3:27am UTC](https://internals.rust-lang.org/t/proposal-for-operator-name/4531/6 "2016-12-30T03:27:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mitsuhiko](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/mitsuhiko/32/379_2.png) [@mitsuhiko](https://internals.rust-lang.org/u/mitsuhiko)\
**Post date:** [December 30, 2016, 8:47am UTC](https://internals.rust-lang.org/t/proposal-for-operator-name/4531/7 "2016-12-30T08:47:42Z")

</div>

unwrap

---

<div class="post-metadata">

**Author:** ![Havvy](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/havvy/32/178_2.png) [@Havvy](https://internals.rust-lang.org/u/Havvy)\
**Post date:** [December 30, 2016, 9:25am UTC](https://internals.rust-lang.org/t/proposal-for-operator-name/4531/8 "2016-12-30T09:25:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jimrybarski](https://avatars.discourse-cdn.com/v4/letter/j/f6c823/32.png) [@jimrybarski](https://internals.rust-lang.org/u/jimrybarski)\
**Post date:** [December 30, 2016, 1:33pm UTC](https://internals.rust-lang.org/t/proposal-for-operator-name/4531/9 "2016-12-30T13:33:12Z")

</div>

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”?

---

<div class="post-metadata">

**Author:** ![MoSal](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/mosal/32/11516_2.png) [@MoSal](https://internals.rust-lang.org/u/MoSal)\
**Post date:** [December 30, 2016, 2:35pm UTC](https://internals.rust-lang.org/t/proposal-for-operator-name/4531/10 "2016-12-30T14:35:22Z")

</div>

Where is the `catch`?

---

<div class="post-metadata">

**Author:** ![Ixrec](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/ixrec/32/6754_2.png) [@Ixrec](https://internals.rust-lang.org/u/Ixrec)\
**Post date:** [December 30, 2016, 7:56pm UTC](https://internals.rust-lang.org/t/proposal-for-operator-name/4531/11 "2016-12-30T19:56:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![nodakai](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/nodakai/32/6161_2.png) [@nodakai](https://internals.rust-lang.org/u/nodakai)\
**Post date:** [January 1, 2017, 2:08pm UTC](https://internals.rust-lang.org/t/proposal-for-operator-name/4531/12 "2017-01-01T14:08:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cuviper](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/cuviper/32/1897_2.png) [@cuviper](https://internals.rust-lang.org/u/cuviper)\
**Post date:** [January 1, 2017, 4:07pm UTC](https://internals.rust-lang.org/t/proposal-for-operator-name/4531/13 "2017-01-01T16:07:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Letheed](https://avatars.discourse-cdn.com/v4/letter/l/df705f/32.png) [@Letheed](https://internals.rust-lang.org/u/Letheed)\
**Post date:** [January 1, 2017, 6:18pm UTC](https://internals.rust-lang.org/t/proposal-for-operator-name/4531/14 "2017-01-01T18:18:05Z")

</div>

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”

---

<div class="post-metadata">

**Author:** ![milesrout](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/milesrout/32/383_2.png) [@milesrout](https://internals.rust-lang.org/u/milesrout)\
**Post date:** [January 4, 2017, 12:27am UTC](https://internals.rust-lang.org/t/proposal-for-operator-name/4531/15 "2017-01-04T00:27:19Z")

</div>

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”.

---

<div class="post-metadata">

**Author:** ![johnthagen](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/johnthagen/32/2005_2.png) [@johnthagen](https://internals.rust-lang.org/u/johnthagen)\
**Post date:** [January 4, 2017, 12:57pm UTC](https://internals.rust-lang.org/t/proposal-for-operator-name/4531/16 "2017-01-04T12:57:55Z")

</div>

I usually refer to ` __init__ ` as “constructor”.

---

<div class="post-metadata">

**Author:** ![MCGG](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@MCGG](https://internals.rust-lang.org/u/MCGG)\
**Post date:** [January 10, 2017, 7:55am UTC](https://internals.rust-lang.org/t/proposal-for-operator-name/4531/17 "2017-01-10T07:55:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)\
**Post date:** [March 25, 2019, 8:27am UTC](https://internals.rust-lang.org/t/proposal-for-operator-name/4531/18 "2019-03-25T08:27:34Z")

</div>

Closed on March 25, 2019, 8:27am UTC

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