Rustc: Add do yeet expressions to allow experimentation in nightly
github.com
github.com
Even if the Rust devs pick throw as a keyword, I'm 100% sure someone will write a macro that will allow you to write yeet! instead.
I'm 66% sure that this macro will end up being included in the dependency chain of a common framework as well…
One of the most obnoxious things is people forcing other people to partake in their own sense of humor.
There are definitely niche features that languish in nightly for years, but this initiative to improve the Try trait and ? operator will have broad appeal and I imagine a good number of people willing to push forward to get it stabilized, at which point they will finally decide on the proper name.
[1]: https://blog.rust-lang.org/2020/12/16/rust-survey-2020.html
Sure, some people won't know the meaning of the word, but I'd argue that "raise" or "throw" meaning "propagate the previously caught error" is not obvious either, we're simply used to it. And it would take no time at all to infer from context/look up and it would be easy to remember.
The biggest potential downside I can think of is opening the floodgates for adding more memey words to the language which could indeed be harmful.
But I do think that having a quirky keyword like this could be a great benefit and not just in the "relating to them kids" sense. In my experience, the biggest obstacle to entering technical fields (a more relevant subtype of this is learning complex programming languages, such as Rust) is, for most people, not the lack of intelligence or resources, but rather the feeling that the insiders of those fields are in a different "category" of people.
This is especially evident in interactions with PhDs. Even smart people, who have themselves successfully studied the fields in question at some point in their lives, upon finding out that someone has a PhD cease all attempts of analyzing what the PhD is saying and just nod along, as if the degree is an impenetrable intellectual barrier.
In spite of being a decent programmer, it took me a long time to start reading computer science papers. Not because they were too complicated or I lacked context, but because the intentionally the language used made the work appear alien.
And including even just a bit of spontaneous humanity can completely break this perception. I find this especially effective in textbooks. All of the textbooks I found most useful added many humorous tidbits. The purpose of those was not to have the amusement counteract boredom, the topics were fascinating by themselves, but rather to demonstrate to the reader that the author is in fact an individual of the same species. This is important, because such connection cannot be established if the book restricts itself solely to its main topic. The author is infinitely more knowledgeable than the reader in the relevant field (otherwise the reader would have no use for the textbook), so this demonstration of equality must come from elsewhere.
…and JavaScript will never be used for more than animating basic hypertext documents.
You can be sure this is not the final keyword.
1. It's only in nightly and needs a feature gate to be enabled, as such accidental usage is impossible and it's not usable at all for most projects (which require stable compatibility).
2. It will be removed in the future there is absolutely no stability guarantees for nightly unstable features, they might literally be gone in the next hour. If you abuse it no one care that you project brakes, the ecosystem knows that and as such stays away from nightly features outside of experimenting (and some unusual target support, like recompiling std with different options for using threads in WASM).
Or in other words it's a very very different situation then unstable JS features which always where a mess you easily could accidentally use and in practice (CSS prefix) had to use all the time. Any feature gated nightly unstable things is better seen as an experimental fork of the compiler which is slightly easier to use then an actual fork.
I HAZ A var ITZ A BUKKIT OF YARN
The correct approach is obviously to separate these two terms, and use "sus" to mark items that require verification, and "yolo" to mark that such verification has been done. Or:
sus fn dangerous() { ... }
yolo { dangerous() } // can only call dangerous inside a yolo blockHow does this improve on (?)?
fn foo(b : bool) -> Result<Bar,Baz> {
...
return Ok(bar);
...
return Err(baz);
}
you can type: fn foo() -> Bar throws Baz {
...
return bar;
...
throw baz; //or yeet, in this proposal
}
and it works exactly identically as the first example. ? still works inside the function just as it normally would. I find the proposal sort of pointless, but also totally harmless, so why not.So in a sense it actually is very similar to `throw` in traditional languages, as it can be caught inside the same function and isn't forced to `return` the error outside the function.
I agree, bikeshedding can be fun, as long as it's not during a meeting.
[1] Steve Klabnik, I know you're going to see this - just wanted to say hi, I hope you're having a nice day :)
There are some other folks around so your point isn't incorrect, only about me.
I've been recently working on a new system that involves a custom IDL. We ended up adding a "[<=]" syntax, but we were worried it would be confusing to new developers. We realized it would make people happy to have an excuse to type smiley faces, though.
try {
if bad_thing {
do yeet Error::new(...);
}
carry_on()
}
Just plain "throw" would probably be fine, but I understand not wanting to bikeshed it at this stage.Weirdly, "yeet" really does convey the sense of "just give up and chuck this thing back instead" that makes it a reasonable nice converse of "try", i.e. "try { yeet }".
Naming bikeshedding is one of the worst kind of bikeshedding.
By now I'm sure of two things:
- People will not agree on a name.
- People will diverge any technical discussion again and again and again because they need to discuss naming.
So in the end most likely there will be some formal or informal survey and then the language teem will do a top-down decisions for one of the more well liked candidates, it's as far as I can tell pretty much the best way to go. (Theoretically you could have a vote, but then you need a proper not easily manipulated voting system people need to take serious, or it will be named not yeet in the end because people are trolls).
EDIT: Also this is not a developer discussion so I guess it's fine here ;)
Pretty much guaranteed, as "do yeet" is also rather long. Likely some new edition introduced keyword/syntax or similar will be used.
Also while yeet is "fun" very few want to see it in the language for real ;)