zlacker

[return to "Go is still not good"]
1. akobol+ld[view] [source] 2025-08-22 11:43:45
>>ustad+(OP)
defer is no worse than Java's try-with-resources. Neither is true RAII, because in both cases you, the caller, need to remember to write the wordy form ("try (...) {" or "defer ...") instead of the plain form ("..."), which will still compile but silently do the wrong thing.
◧◩
2. xyzzyz+Tf[view] [source] 2025-08-22 12:03:22
>>akobol+ld
Sure, true RAII would be improvement over both, but the author's point is that Java is an improvement over Go, because the resource acquisition is lexical scoped, not function-scoped. Imagine if Java's `try (...) { }` didn't clear the resource when the try block ends, but rather when the wrapping method returns. That's how Go's defer works.
◧◩◪
3. akobol+Ag[view] [source] 2025-08-22 12:07:49
>>xyzzyz+Tf
Can't you create a new block scope in Go? If not, I agree. If so, just do that if you want lexical scoping?
[go to top]