--
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...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/375e05d7-151a-4cd9-bb60-bc617aa20bebn%40googlegroups.com.
--
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...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/375e05d7-151a-4cd9-bb60-bc617aa20bebn%40googlegroups.com.
It's also unclear to me why you think using "any" would be less safe. You still have to use a type-assertion or type-switch to disambiguate the two cases. If the compiler allowed your example it might catch obvious mistakes at compile time but you still have to hand write code to detect at run-time which case is in effect. And such code should always have a "Oops! Got the wrong type" path.
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.
On Mar 14, 2026, at 12:52 AM, Kurtis Rader <kra...@skepticism.us> wrote:
--
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...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/CABx2%3DD9GSrE0OvRxkJDcdjYvXLKnb%2BLeht2NJK3GsnhNYSXDmQ%40mail.gmail.com.