Skip to content

Commit 42331a9

Browse files
committed
rfc, try-expr: review 'result' keyword.
1 parent 100a626 commit 42331a9

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

text/0000-try-expr.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,36 @@ However, `trap` is used as an error handler in at least one langauge.
478478
It also does not have the familiarity that `try` does have and is entirely
479479
inconsistent wrt. naming in the standard library.
480480

481+
## Alternative: reserving `result`
482+
483+
1. **Fidelity to the construct's actual behavior:** Somewhat good
484+
2. **Precedent from existing languages:** None
485+
3. **Brevity / Length:** 6
486+
4. **Consistency with the naming of the trait used for `?`:** Inconsistent
487+
5. **Consistency with related libstd fn conventions:** Inconsistent
488+
6. **Risk of breakage:** Very high
489+
- **Used in std:** [*Yes*](https://doc.rust-lang.org/nightly/std/?search=result) for the `{std, core}::result` modules.
490+
- **Used as crate?** [*Yes*](https://crates.io/crates/result). 6 reverse dependencies (transitive closure).
491+
- **Usage (sourcegraph):** **43+** regex:
492+
```
493+
repogroup:crates case:yes max:400
494+
\b((let|const|type|)\s+result\s+=|(fn|impl|mod|struct|enum|union|trait)\s+result)\b
495+
```
496+
7. **Consistency with old learning material:** Untaught
497+
498+
## Review
499+
500+
[final encoding]: http://okmij.org/ftp/tagless-final/course/lecture.pdf
501+
502+
The fidelity of `result` is somewhat good due to the association with the
503+
`Result` type as well as `Try` being a [final encoding] of `Result`.
504+
505+
However, when you consider `Option`, the association is less direct,
506+
and thus it does not fit `Option` and other types well.
507+
508+
The breakage of the `result` module is however quite problematic,
509+
making this particular choice of keyword more or less a non-starter.
510+
481511
## Alternative: a smattering of other possible keywords
482512

483513
There are a host of other keywords which have been suggested.

0 commit comments

Comments
 (0)