They are not arguing, they are asking questions to improve their understanding.
The context of the thread, however, very much is people arguing. See for example graue's post a few levels up.
Is -B for disabling bounds checking no longer supported?
Looking at the code it seems it has been removed.
> ... I would certainly never enable such a thing in real code.
So I assume you don't do C or C++. :)
While I agree with you, there are certain cases where it might help. That is why most strong typed languages with native compilers allow to selectively disable bounds checking, since the Pascal/Modula-2 days.
I only support doing this if profiling proves it is really worth it, give the security issues.
package main
func main() {
slice := []string{"first", "second", "third"}
println(slice[1])
slice = slice[0:2]
println(slice[2])
}
Compile with go build -gcflags -B wat.go
./wat
Output second
third
Without the `-B` you'll get a runtime panic. I'm on Go 1.1. (Maybe it's removed in tip?)Next time I better checkout and do a proper grep.
If C had a simple universal switch for bounds checking, I'd turn it on everywhere and immediately revoke commit privileges for anyone on my team who turned it back off. But it doesn't, and necessarily can't, making your statement nothing more than an annoying exercise in wrongful pedantry. It is contextually obvious I was talking about Go code and/or languages/compilers with such a switch.
go tool 6g -help
The `-B` switch will disable bounds checks. You can use it like this: go build -gcflags '-B'
Not possible in Go, the runtime will panic.
> there's still a hell of a lot of C code out there with array overflow errors
An extremely easy error to make in many cases, which is why modern programming languages bounds-check.
> Exception stack traces
Go will give you a very nice stacktrace should it ever panic.
> I have no experience with Go
Which is really the problem. People keep arguing about Go's merits based on no substantive understanding.
It's very obvious which operations can fail without a panic in Go, because functions explicitly return error objects -- actual error objects, not magic numbers. The return signature for the Go equivalent of fread is (int, error), not (int).