> I just expect type asserting on a non-nil interface value shouldn't panic.

of course it should panic if the interface holds an unexpected value
and you're not checking for correctness with the comma-ok pattern.

Go is a statically typed language and by asserting the wrong type on a
variable you have an created an obviously incorrectly typed program.
If the compiler was able to deduce that the interface was holding an
incorrect value at compile time it would never have allowed such a
program to be compiled.

the following two examples both look ridiculous to a Go programmer:

    var i int = 42
    var b = bool(i)
    // b is now false

vs

   var i = interface{}(42)
    var b = i.(bool)
    // b is now false

One shouldn't be able to turn 42 into a "false" in Go. maybe in other
languages, but not Go.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to