←back to thread

Go is still not good

(blog.habets.se)
644 points ustad | 1 comments | | HN request time: 0.208s | source
Show context
gwd ◴[] No.44983375[source]
Anyone want to try to explain what he's on about with the first example?

    bar, err := foo()
    if err != nil {
      return err
    }
    if err := foo2(); err != nil {
      return err
    }
The above (which declares a new value of err scoped to the second if statement) should compile right? What is it that he's complaining about?

EDIT: OK, I think I understand; there's no easy way to have `bar` be function-scoped and `err` be if-scoped.

I mean, I'm with him on the interfaces. But the "append" thing just seems like ranting to me. In his example, `a` is a local variable; why would assigning a local variable be expected to change the value in the caller? Would you expect the following to work?

    int func(a *MyStruct) {
      a = &MyStruct{...}
    }
If not why would you expect `a = apppend(a, ...)` to work?
replies(4): >>44983418 #>>44983426 #>>44983435 #>>44983907 #
1. sublimefire ◴[] No.44983426[source]
edit: the main rant about err was that it is left in scope but I believe the author does not like that