5 ms·
This may be intuitively correct, but to my mind it is architecturally wrong. A good language should not tolerate ambiguity and offer to guess which behavior is
by nine_k 1y ago
This may be intuitively correct, but to my mind it is architecturally wrong. A good language should not tolerate ambiguity and offer to guess which behavior is correct.
- tayo42 1y agoWhy is it ambiguous though? The second URL is nested Are thy not accessed like opts.URL == abc.com and opts.BarConnectionOptions.URL == xyz.com what leads you think otherwise?
- tsimionescu 1y agoIf there were no duplicate URL field, say they were called FooURL and BarcoURL, you could access them as `opts.FooURL` and `opts.BarcoURL`. They are both fields of `opts`, via embedding. It's just that FooURL is embedded directly, while BarcoURL is coming from two levels of embedding.
- wild_egg 1y agoIt's not ambiguous though. The behaviour is very clearly defined in the language spec. https://go.dev/ref/spec#Selectors https://go.dev/ref/spec#Selectors As far as language specs go, Go's is really quite concise and I strongly encourage everyone I onboard to spend an afternoon reading it end to end at some point in their first couple weeks.