On Wed, Sep 2, 2020 at 3:45 AM targe...@gmail.com <target....@gmail.com> wrote:
>
> > Other people have said this too, but I want to emphasize that there
> are not 4 potential states of an interface value. There are 2
> potential states: 1) interface does not hold any value, and is == nil;
> 2) interface holds a value, and is != nil.
>
> Indeed, there are 2 states of interface observable from outside. Although one 
> of these observable states gets expressed through 2 states invisible to outer 
> world. Which isn't a problem on its own.
>
> > When you start talking about an interface as a fat pointer you are
> talking about how those 2 states are implemented. There are other
> possible implementations
>
> Yes. And that's not an issue on its own. The issue is, such implementation 
> detail kind of "leaks" sometimes and bites you when you don't expect. And it 
> does so because the way it gets constructed omits one specific detail of 
> conversion from pointer to interface.

I don't think that is correct.  The implementation detail never leaks.
An interface always either holds a valid value (is != nil) or does not
hold a valid value (is == nil).

I believe the confusion is due to the overloading of "nil".  It means
both an invalid interface and an invalid pointer, but you are
permitted to store an invalid pointer in a valid interface.

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/CAOyqgcVG%2BY8d9gtnR7%3DGmdN5eiPQ1ZGP3XoWYCjW2b%3Dbkj1z6w%40mail.gmail.com.

Reply via email to