# Renaming task failure

**URL:** <https://internals.rust-lang.org/t/renaming-task-failure/310>\
**Category:** bikeshed (deprecated)\
**Created:** [August 3, 2014, 10:40pm UTC](https://internals.rust-lang.org/t/renaming-task-failure/310 "2014-08-03T22:40:16Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![aturon](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/aturon/32/3272_2.png) [@aturon](https://internals.rust-lang.org/u/aturon)\
**Post date:** [August 3, 2014, 10:40pm UTC](https://internals.rust-lang.org/t/renaming-task-failure/310/1 "2014-08-03T22:40:16Z")

</div>

The fact that we use “failure” (and `fail!`) to refer to our unwinding mechanism often makes it awkward to talk about _other_ kinds of failure. For example, for a function returning a `Result`, you cannot talk about the operation “failing” without risking ambiguity. You instead have to say something more cumbersome like “the `Err` case” or "when the operation produces an `Err`".

The terminology is especially problematic as we move away from task failure and toward `Result`, since you need to talk about the success/failure of the latter much more often than the former.

A strawman proposal: since task failure entails unwinding (and is essentially exception handling with limited catch points), call it “throwing”, with macro `throw!`. Then operations like the current `recv_opt` could instead be labeled `recv_catch`.

The main downside of using “throw”, of course, is that it suggests we have full-blown exception handling. I’d love to hear additional ideas.

cc @brson @alexcrichton @nikomatsakis

---

<div class="post-metadata">

**Author:** ![alexcrichton](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/alexcrichton/32/4501_2.png) [@alexcrichton](https://internals.rust-lang.org/u/alexcrichton)\
**Post date:** [August 4, 2014, 12:03am UTC](https://internals.rust-lang.org/t/renaming-task-failure/310/2 "2014-08-04T00:03:39Z")

</div>

I always love to check [synonyms](http://thesaurus.com/browse/failure), and it sounds like we should start saying “task faux pas”!

On a more serious note, I’m personally ok with the ambiguity, but I could see us renaming it as well. We could tighten up how we refer to these two notions of failure like we have with immutable/shared reference as well. For example we could say that _task failure_ is the thing you can’t catch whereas _failure_ is just “I couldn’t finish” and generally refers to an error case.

On the other hand, renaming may not be so bad. There would be a lot of documentation to update, but that’s not the end of the world. I like the `recv_catch` pairing with `throw!`, but I think that `throw!` invokes the notion of try/catch too much to use it. You’re also not really catching a `throw!` with `recv_catch`, you’re more preventing a `throw!` (in a sense).

One other option may be to call this a “task abort” with an `abort!` macro. The term abort brings with it “no, you cannot catch this” and we could refer to something like `intrinsics::abort` as a “process abort”

---

<div class="post-metadata">

**Author:** ![Gankra](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/gankra/32/6002_2.png) [@Gankra](https://internals.rust-lang.org/u/Gankra)\
**Post date:** [August 4, 2014, 12:47am UTC](https://internals.rust-lang.org/t/renaming-task-failure/310/3 "2014-08-04T00:47:45Z")

</div>

I like the notion of abort as it emphasizes the criticality of the error. May I offer for consideration `crash!`? Failures are expected to happen, and are potentially recoverable. I can fail to find a file, or fail to get the head of an empty list. A crash on the other hand, invokes (to me) the notion of "there's nothing you can do at this point, we're dead".

Or perhaps in that same vein, `die!` or `kill!`

[![](http://static02.mediaite.com/themarysue/uploads//2011/01/chrome-dead-jim-sad-tab.png) ](http://static02.mediaite.com/themarysue/uploads//2011/01/chrome-dead-jim-sad-tab.png)

---

<div class="post-metadata">

**Author:** ![jimuazu](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/jimuazu/32/77_2.png) [@jimuazu](https://internals.rust-lang.org/u/jimuazu)\
**Post date:** [August 4, 2014, 1:04am UTC](https://internals.rust-lang.org/t/renaming-task-failure/310/4 "2014-08-04T01:04:29Z")

</div>

`die` is familiar from Perl, with similar meaning

---

<div class="post-metadata">

**Author:** ![nikomatsakis](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/nikomatsakis/32/5410_2.png) [@nikomatsakis](https://internals.rust-lang.org/u/nikomatsakis)\
**Post date:** [August 4, 2014, 11:05am UTC](https://internals.rust-lang.org/t/renaming-task-failure/310/5 "2014-08-04T11:05:39Z")

</div>

Abort sounds pretty good. We often use the term abort now to mean "a call to `abort(3)`", but we can always say “process abort” in that case (and, i’ve noticed, we often qualify that with “abort, as in, kill the process”). I tend to agree that saying “we don’t have exceptions” (but we do “throw!”) is likely to get us in trouble, even if it’s true, because it will be confusing. Having exceptions (or, at least, unwinding) by another name seems to be a reasonable and effective way of emphasing that this is not the normal mode of error handling (see Go’s `panic`/`recover`).

---

<div class="post-metadata">

**Author:** ![pnkfelix](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/pnkfelix/32/110_2.png) [@pnkfelix](https://internals.rust-lang.org/u/pnkfelix)\
**Post date:** [August 4, 2014, 3:02pm UTC](https://internals.rust-lang.org/t/renaming-task-failure/310/6 "2014-08-04T15:02:24Z")

</div>

Any reason we shouldn’t use `unwind!` ?

(Is it not sufficiently severe sounding?)

---

<div class="post-metadata">

**Author:** ![alexcrichton](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/alexcrichton/32/4501_2.png) [@alexcrichton](https://internals.rust-lang.org/u/alexcrichton)\
**Post date:** [August 4, 2014, 8:52pm UTC](https://internals.rust-lang.org/t/renaming-task-failure/310/7 "2014-08-04T20:52:49Z")

</div>

The current implementation of task failure is related to unwinding, but I think we don’t want to tie the concept of a task failure to the exact process of unwinding. I think in the past there may have been ideas of how to move away from unwinding, and it would be nice to keep those options in play (not that I know of them though!)

---

<div class="post-metadata">

**Author:** ![aturon](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/aturon/32/3272_2.png) [@aturon](https://internals.rust-lang.org/u/aturon)\
**Post date:** [August 4, 2014, 10:21pm UTC](https://internals.rust-lang.org/t/renaming-task-failure/310/8 "2014-08-04T22:21:46Z")

</div>

It sounds like `abort` is the best bet for a replacement. I’m curious whether others share my concern/frustration about the current terminology? Do we think it’s worth changing this?

---

<div class="post-metadata">

**Author:** ![reem](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/reem/32/167_2.png) [@reem](https://internals.rust-lang.org/u/reem)\
**Post date:** [August 5, 2014, 1:52am UTC](https://internals.rust-lang.org/t/renaming-task-failure/310/9 "2014-08-05T01:52:43Z")

</div>

abort! to replace fail! would pair well with kill! instead of intrinsics::abort. kill! works well because it sounds like it does what it does: kill the process.

---

<div class="post-metadata">

**Author:** ![rkjnsn](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/rkjnsn/32/5368_2.png) [@rkjnsn](https://internals.rust-lang.org/u/rkjnsn)\
**Post date:** [August 5, 2014, 5:15am UTC](https://internals.rust-lang.org/t/renaming-task-failure/310/10 "2014-08-05T05:15:26Z")

</div>

I like die! because I am familiar with it from other languages, and it would do exactly what I would expect.

---

<div class="post-metadata">

**Author:** ![steveklabnik](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/steveklabnik/32/4524_2.png) [@steveklabnik](https://internals.rust-lang.org/u/steveklabnik)\
**Post date:** [August 5, 2014, 6:38pm UTC](https://internals.rust-lang.org/t/renaming-task-failure/310/11 "2014-08-05T18:38:39Z")

</div>

Yeah, with the talk of maybe removing/changing unwinding, seems bad to rename it to that.

I do agree that fail has problems right now.

Go uses panic and recover: [http://blog.golang.org/defer-panic-and-recover](http://blog.golang.org/defer-panic-and-recover)

---

<div class="post-metadata">

**Author:** ![arcto](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/arcto/32/45_2.png) [@arcto](https://internals.rust-lang.org/u/arcto)\
**Post date:** [August 7, 2014, 3:08pm UTC](https://internals.rust-lang.org/t/renaming-task-failure/310/12 "2014-08-07T15:08:56Z")

</div>

How about `my_bad!` or `epic fail!`? J

**+1** for `abort!` as it’s probably the best alternative – unless there’s even a small chance that these unwindings could be “caught” in a future Rust, in which case we’re really talking about exceptions.

---

<div class="post-metadata">

**Author:** ![glaebhoerl](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/glaebhoerl/32/1978_2.png) [@glaebhoerl](https://internals.rust-lang.org/u/glaebhoerl)\
**Post date:** [August 7, 2014, 3:21pm UTC](https://internals.rust-lang.org/t/renaming-task-failure/310/14 "2014-08-07T15:21:42Z")

</div>

I think if we ever add a mechanism for intra-task catchable exceptions, it should be semantically and syntactically distinct from task failure / abort / whatever (even if under the hood, they are both implemented by unwinding).

Another potential name here might be `error!`, which is what Haskell uses for their equivalent. But this conflicts with the current `error!` for logging, and might also be confusable with the `Err` variant of `Result`s.

(Gah, I deleted my previous top-level comment so I could make it a reply to the particular comment I’m responding to instead, and now it’s complaining that the body is too similar…)

---

<div class="post-metadata">

**Author:** ![arcto](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/arcto/32/45_2.png) [@arcto](https://internals.rust-lang.org/u/arcto)\
**Post date:** [August 7, 2014, 3:44pm UTC](https://internals.rust-lang.org/t/renaming-task-failure/310/15 "2014-08-07T15:44:27Z")

</div>

Instead of having full-fledged exception handling, I think, a lot of safe and deliberate recovery could be done if you had a kind of _cheap-to-set-up_ task that “lends” its caller’s thread _(i.e. not starting a new thread for the task)_.

* * *

Another really stupid/ingenious idea I’ve had is _parameterised recovery points_, akin to lifetimes for parameters.

---

<div class="post-metadata">

**Author:** ![brson](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/brson/32/5197_2.png) [@brson](https://internals.rust-lang.org/u/brson)\
**Post date:** [August 7, 2014, 6:13pm UTC](https://internals.rust-lang.org/t/renaming-task-failure/310/16 "2014-08-07T18:13:07Z")

</div>

I am also constantly frustrated about the terminology whenever I write about error handling in Rust. My suspicion is that this pain will be amplified over time.

---

<div class="post-metadata">

**Author:** ![ecl3ctic](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/ecl3ctic/32/54_2.png) [@ecl3ctic](https://internals.rust-lang.org/u/ecl3ctic)\
**Post date:** [August 8, 2014, 9:33am UTC](https://internals.rust-lang.org/t/renaming-task-failure/310/17 "2014-08-08T09:33:59Z")

</div>

I like abort!. It tells you exactly what’s going to happen, whereas fail! simply sounds like something has gone wrong.

---

<div class="post-metadata">

**Author:** ![liigo](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/liigo/32/454_2.png) [@liigo](https://internals.rust-lang.org/u/liigo)\
**Post date:** [August 8, 2014, 1:48pm UTC](https://internals.rust-lang.org/t/renaming-task-failure/310/18 "2014-08-08T13:48:39Z")

</div>

abort! Looks nice, +1!

---

<div class="post-metadata">

**Author:** ![bachm](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/bachm/32/3418_2.png) [@bachm](https://internals.rust-lang.org/u/bachm)\
**Post date:** [August 8, 2014, 4:29pm UTC](https://internals.rust-lang.org/t/renaming-task-failure/310/19 "2014-08-08T16:29:49Z")

</div>

Wouldn’t we be talking about task abortion if `abort` is chosen? I think I prefer `crash`.

---

<div class="post-metadata">

**Author:** ![arcto](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/arcto/32/45_2.png) [@arcto](https://internals.rust-lang.org/u/arcto)\
**Post date:** [August 8, 2014, 4:57pm UTC](https://internals.rust-lang.org/t/renaming-task-failure/310/20 "2014-08-08T16:57:53Z")

</div>

I don’t particularly like “crash” because I think it carries a connotation of uncontrolled execution. I’d like to think of this kind of unwinding as safe and planned.

---

<div class="post-metadata">

**Author:** ![reem](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/reem/32/167_2.png) [@reem](https://internals.rust-lang.org/u/reem)\
**Post date:** [August 8, 2014, 10:34pm UTC](https://internals.rust-lang.org/t/renaming-task-failure/310/21 "2014-08-08T22:34:04Z")

</div>

`abort` has a nice semantic meaning - it doesn’t sound unsafe like `crash` or `die` but it does sound like something you probably shouldn’t do unless you have no other outlet.

It just makes sense in many cases - what do I do if that thing I expected to be x and it inexplicably isn’t? _abort_ the operation.

[Next page](https://internals.rust-lang.org/t/renaming-task-failure/310.md?page=2)
