It's actually plain text but copied right from my editor with the theme styles, I'll use the playground for future examples.
Thank you for clarifying. I do see how the compiled version will need to be repetitive, although as you mentioned this piece of code is not a common case. في Friday, August 25, 2023 في تمام الساعة 11:43:05 PM UTC+3، كتب Ian Lance Taylor رسالة نصها: > On Fri, Aug 25, 2023 at 7:43 AM محمد بومنذر > <mohamme...@gmail.com> wrote: > > > > I'm writing a parser based on Go's `encoding/xml`, I tried to use the > following pattern but it was deemed invalid: > > > > ``` > > To me, it'd make sense if it was allowed since both types are structs > and both of them share the field `Name` with the subsequent field `Local`. > > > Please post code as plain text or as a link to the Go playground, not > as an image. Images are much harder to read, and there is no reason > to use them for plain code. Thanks. > > We are unlikely to implement such a language feature. We would have > to have careful definitions of what kinds of code are permitted in a > case with multiple types. And since in general there is no reason to > expect that the fields are at the same location, we would have to > compile the case differently for each type anyhow. And the code might > actually behave quite differently; should we permit code like > > switch x := v.(type) { > case []int, map[int]int: > return x[1] > } > > Ian > -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/312da70b-11c3-43b1-b53e-6d1a8e622becn%40googlegroups.com.