On Fri, Mar 13, 2026 at 10:40 PM Axel Wagner <[email protected]> wrote:
> In common parlance, "type-safe" means exactly, that a class of runtime > errors is prevented at compile time. That is the purpose of types. > > A function constrained on `ReadStringer` would not be safer to *write*, > because, you would still need a type-switch that would need to include a > runtime panic branch. But it would be safer to *use*, because the compiler > would prevent a user from ever triggering that runtime panic. > I guess I'm showing my age. But if you have to write an explicit run time type switch/assertion then you should assume the compile time type constraint might allow an unexpected type to "leak" into your function. If the O.P.'s example was supported by the compilation toolchain that might be impossible, in theory, but I would assume it's still possible if I have to write code to disambiguate which type I received. -- Kurtis Rader Caretaker of the exceptional canines Junior and Hank -- 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 [email protected]. To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/CABx2%3DD-xy8x7jbP0Hh7SDh2fDK0tQDaC94Gr8tPf_Zkvntw%2B8w%40mail.gmail.com.
