Re:Why I like Golang's interfaces
by camus2 on Thursday April 13, 2017 @07:47PM
(#14111714)
That's not a union, that's a product of 2 types. A union is one or the other but not both. You rw here is both a reader and a writer, you can't pass something that is either a reader or a writer, which makes your snippet useless in use-cases where unions are appropriate.
Of course, Go compiler itself uses "unions" with runtime-tricks to implement them. But we're talking about runtime then, not compile time type safety and correctness.
Of course, Go compiler itself uses "unions" with runtime-tricks to implement them. But we're talking about runtime then, not compile time type safety and correctness.