← Back to context

Comment by thomashabets2

1 day ago

The standard library recovers from the panic, and program continues.

This means that if you do:

    func (f Foo) String() string {
      some.Lock()
      t := get_something()
      some.Unlock()
      t = transform_it(t)
      return t
    }

And `get_something()` panics, then the program continues with a locked mutex. There are more dangerous things than a deadlocked program, of course.

It's non-optional to use defer, and thus write exception safe code. Even if you never use exceptions.