rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
96.55k stars 12.47k forks source link

Tracking Issue for `ops::Yeet` (`feature(try_trait_v2_yeet)`) #96374

Open scottmcm opened 2 years ago

scottmcm commented 2 years ago

Feature gate: #![feature(try_trait_v2_yeet)]

This is a tracking issue for standard library additions related to https://github.com/rust-lang/rust/issues/96373, which for now means the ops::Yeet struct and related impls.

It currently exists experimentally. Per the lang process, this cannot go further than experimenting without an approved RFC -- and will certainly not stabilize under the name Yeet. Please try this out and give experience reports, but be aware that it may well change drastically or be removed entirely.

Public API

// core::ops
pub struct Yeet<E>(pub E);

impl<T> ops::FromResidual<ops::Yeet<()>> for Option<T>;
impl<T, E, F: From<E>> ops::FromResidual<ops::Yeet<E>> for Result<T, F>;

Steps / History

Unresolved Questions

pro465 commented 2 years ago

if the name as it is gets stabilized, that'd be the greatest thing to ever happen in CS history.

everybody, pleeeease don't suggest changing the name so that i can witness the moment πŸ™

VixieTSQ commented 2 years ago

As much as I love the name yeet, and I would not be mad if it gets stabilized as yeet, the name should probably be throw, or if we must be different then the anyhow crate already has a cool name: bail. In that case I'm not sure what the catch counterpart would be named. But those are the two names I'm putting on the table.

AndyGozas commented 2 years ago

I really don't think that the name should be any different from what it is in most other languages. If throw is changed to yeet then the only next step would be to use yoink instead of catch when that keyword comes up, but naming more and more things with what's essentially slang terms, raises the entry bar for the Rust language, especially for those who don't use English as their first language. Words like throw and catch are already known by many developers, and are simple enough even for those who are minimally experienced in English.

heavyrain266 commented 2 years ago

The word yeet surely looks "funny", but please be real because if we don't want some mainstream keywords like throw, what about toss? You can say "Hey, rustc toss an error here.", which sounds natural.

Personally, using slang words in programming language feels really unprofessional. Perhaps it makes sense to be used in some esolangs but not in the language used by mostly mature (as in age) community and big tech companies such as Mozilla, Twitter, Google, Microsoft and others.

TheRawMeatball commented 2 years ago

I think it should be either yeet or throw. If we're going to do something fun (which I'd personally support) it should be yeet given the community support it already has, and if not, we should stick to what is already pretty much the standard and go with throw.

dnsco commented 2 years ago

"Yeet" was chosen as a placeholder name to prevent bike-shedding and make room for implementation unhindered.

My understanding is that there will be a time to voice what you think the keyword should be, but for now, let's yeet those lines of inquiry.

VixieTSQ commented 2 years ago

"Yeet" was chosen as a placeholder name to prevent bike-shedding and make room for implementation unhindered.

And yet there appears to be a lot of bike-shedding.. I think it backfired...

Shfty commented 2 years ago

"Yeet" was chosen as a placeholder name to prevent bike-shedding and make room for implementation unhindered.

With the unfortunate side-effect of planting a highly noticeable name - and accompanying link to this issue - in the std::ops documentation, which practically begs the reader to click on it and ask why on earth meme-tier keywords are appearing in experimental.

It's reassuring to see "at the very least it will not stabilize under the name Yeet" in the description, but it's an unnecessary distraction from whatever promped the aforementioned docs.rs browsing to begin with.

dpc commented 2 years ago

"Yeet" was chosen as a placeholder name to prevent bike-shedding and make room for implementation unhindered.

I think it was chosen, so work can be done before bikesheding ends. Bikesheding itself is unavoidable.

toadslop commented 1 year ago

"Yeet" was chosen as a placeholder name to prevent bike-shedding and make room for implementation unhindered.

I think what was meant was that the author didn't want to bikeshed, so it was named the first thing that came to mind. Perhaps the thought that giving it that name would mean that the main thing someone who doesn't know much about the implementation or what it's for would be able to do nothing but bike-shed the name. And would happily do so.

yoshiyahoo commented 1 year ago

I'm not sure about this being a feature. The question mark operator signals the intent to return well enough, and while using the Err variant is more verbose, I think it's a decent enough way to handle errors. If this feature was to ever be added however, I would use the yeet keyword since it's more fun.

nyabinary commented 9 months ago

When are we stabilizing the yeet keyword :P

gorentbarak commented 9 months ago

oh my god we need this. please. i need this. all rustaceans need this. πŸ₯ΊπŸ‘‰πŸ‘ˆ