Just realised I accidentally replied to Ian off-list:

> My question is why something that could be caught at compile time is not
> > caught at compile time:
>
> I suspect mostly because nobody thought of it.
>
> That said, note that this in effect a language change.  It is possible
> to construct a program that currently works into a program that after
> this change is made will fail to compile.


Yes, I can see it would be a change of sorts.


> So while we could make this
> change, it would have to be done by changing the language spec.  I
> don't know whether it is worth doing; is it a common problem?
>

I don't know either... but when I didn't catch this until runtime it
"surprised" me.

A candidate for go vet perhaps, to side step the language change if there
wasn't a sufficient case for doing so?



On 4 April 2017 at 15:27, Ian Lance Taylor <i...@golang.org> wrote:

> On Tue, Apr 4, 2017 at 3:41 AM, Paul Jolly <p...@myitcv.org.uk> wrote:
> >> When you insert a value keyed by S{}, the compiler creates a value of
> >> type I which has S as its dynamic type and S{} as its value.
> >>
> >> The program as speficied panics with
> >
> >
> > Apologies if it wasn't clear from my original email, but I understand why
> > this panics; I further acknowledge the behaviour is consistent with the
> > spec.
> >
> > My question is why something that could be caught at compile time is not
> > caught at compile time:
>
> I suspect mostly because nobody thought of it.
>
> That said, note that this in effect a language change.  It is possible
> to construct a program that currently works into a program that after
> this change is made will fail to compile.  So while we could make this
> change, it would have to be done by changing the language spec.  I
> don't know whether it is worth doing; is it a common problem?
>
> 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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to