Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal: errors: - #52380

Closed
switchupcb opened this issue Apr 16, 2022 · 2 comments
Closed

proposal: errors: - #52380

switchupcb opened this issue Apr 16, 2022 · 2 comments
Labels
error-handling Language & library change proposals that are about error handling. FrozenDueToAge LanguageChange Suggested changes to the Go language Proposal v2 An incompatible library change
Milestone

Comments

@switchupcb
Copy link

_ to ignore the error. - to return error if not nil. ~ to wrap da err.

func bezo(baller, dollers string) error {
    bucko, - := strconv.Atoi(baller)
    bucks, _ := strconv.Atoi(dollers)
    fmt.Println("$:", bucko + bucks)

    return nil
}

Error are values in Go, so don't bother using a keyword or special function for it. Also, this is backwards compatible for the boomers out there.

But what about minus sign. How can we tellll???

It's on the left hand side. Do more leetcode or something. Sure. ? would be fine; it's not the same key as _ though.

But what about handle and defer???

Well, do you handle and defer your other values? N- oh, yeah? You do? Go back to leetcode. Now.

But what about check???

Last time I checked, I didn't use keywords for integers (and other values). Leetcode for even asking that question. You peasant.

But what abou-

image

Other Proposals

The issue with the other proposals is that they don't believe in themselves enough. Too much big words. All that justification. We are GO programmers. Our personal advertisements consist of Lamborghini and McClaren... We don't search Google. Google searches us. Listen up.

I will travel across the land, searching far and wide.
To teach Go devs to understand, the power that's inside.
(Go Errors, Gotta Catch Em All) It's you and me
I know it's my destiny
(Go Errors) Oh, you're my best friend
In programs we must defend
(Go Errors, Gotta Catch Em All) If err not nil
A return will pull us through
You teach me and I'll teach you
Go Errors! (Gotta Catch 'em all) Gotta Catch 'em all (Go Errors!)

@gopherbot gopherbot added this to the Proposal milestone Apr 16, 2022
@seankhliao
Copy link
Member

Duplicate of #50207 , #42214 , #32601 , #33150

@seankhliao seankhliao added LanguageChange Suggested changes to the Go language v2 An incompatible library change error-handling Language & library change proposals that are about error handling. labels Apr 16, 2022
@switchupcb
Copy link
Author

Reopen Request: All of those use ? or ! but this one uses - and ~. Plus, it's 2022.

Also, you could add a symbols section on your website @seankhliao.

On Duplicates
#50207 (from 2021): closed as duplicate for next issue.
#42214 (from 2020): closed as duplicate for #40432. This one suggests using it as a func alias; it's not a duplicate.
#32601: closed because @griesemer try who is the person who called it cryptic.
#33150: what's going on in there?!
#32884 (from 2019): closed cause cryptic by @ianlancetaylor

On cryptic

This seems quite cryptic for people unfamiliar with Go. That's not a fatal problem, but it is a cost.

Go has been designed with a strong emphasis on readability; we want even people unfamiliar with the language to be able to make some sense of Go code (that doesn’t imply that each name needs to be self-explanatory; we still have a language spec, after all). So far we have avoided cryptic abbreviations or symbols in the language, including unusual operators such as ?, which have ambiguous or non-obvious meanings.

I'm not a Rust zealot but... If this is cryptic then what justifies _. Why does try builtin function for A VALUE get 900,000 comment discussion, but every single symbol proposal gets instantly shut down for cryptic. If an error is a value, there is no avoiding using if to act on it. Errors as values implies that whatever keyword that gets introduced also applies to values (i.e int, string). In contrast, a symbol is consistent with _ behavior, backwards compatible, and (in the case of dash) simple for a person to understand.

The actual concern for symbols is the ability to do stuff like fmt.Errorf("msg: %w", err). However, specifying that in a function call would be horrible to read. As we see, it either involves another function at the top of the page, or somewhere in the 4th dimension. Using symbols at-assignment is a sweet-spot, cause you can only use one per line at maximum which maintains explicitness.

@golang golang locked and limited conversation to collaborators Apr 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
error-handling Language & library change proposals that are about error handling. FrozenDueToAge LanguageChange Suggested changes to the Go language Proposal v2 An incompatible library change
Projects
None yet
Development

No branches or pull requests

3 participants