4 ms·
> elides nil checks. Are you sure? This would only work in a world with a single goroutine.
by richardfey 5y ago
> elides nil checks.
Are you sure? This would only work in a world with a single goroutine.
- chrisseaton 5y agoIt’s a basic optimisation. Java does it as well, for example, and it’s safe. But it’s not part of the type system and it’s not what people here are talking about.
- simiones 5y agoIt's more complex in practice, since you need to also check that the compiler needs to see the entire lifetime of the variable to check if it's not modified asynchronously, as you say. But for many common use cases, this is not hard to confirm, especially since the Go compiler has access to the entire source code of the entire program (unlike in C++, Java, etc).