Hi, this thread <https://groups.google.com/g/golang-nuts/c/zeSX2iwvLKc> had me wonder again about a spec question that recently came up which I didn't have an answer to: Where does the spec say, which recursive type declarations are allowed and which aren't? For example, why is `type T *T` legal, but `type T T`ยน isn't?
To be clear: I know why we *can't* make `type T T` et al. legal - the compiler needs to know the size of the values and it can't know it from a declaration like `type T T`. I'm wondering how this follows from the spec. I haven't read through all of the spec in a while, so I might just be missing an obvious section. But it doesn't seem to be described in the section about type declarations <https://golang.org/ref/spec#Types> and some obvious keyword searches like "recursive" or "size" didn't turn up anything meaningful, as far as I can tell. But feel free to point me to a section I overlooked, and apologies if the question makes me seem lazy because it ends up being obvious :) [1] Maybe `type T struct { T }` is a better example, as it's a type-literal, not a type name - just like `type T *T`. -- 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 on the web visit https://groups.google.com/d/msgid/golang-nuts/CAEkBMfFR4G%3DisUWLa7aWpr%3DD_tn942kh%3DX%3DWE%3D9ADQCiT9Lncw%40mail.gmail.com.
