On Thu, Feb 27, 2025 at 9:49 AM cpu...@gmail.com <cpui...@gmail.com> wrote:
>
> Thanks Ian, you are of course correct- but I still don't get it. Thank you 
> for taking the time.
>
> > m.EqualName has to mean something. The Go language defines it as
> meaning the field in m's type, rather than the embedded method.
>
> Doesn't have meter an embedded field of type EqualName (the interface)?

It has an embedded field whose name is EqualName and whose type is
EqualName. It's though the code said

type meter struct {
    EqualName EqualName
    DifferentNamer DifferentNamer
}

except that methods and fields of the embedded types are promoted.


> > Therefore, the type meter does not have a method EqualName. Therefore,
> the type meter does not implement the EqualName interface.
>
> meter doesn't. But impl's methods get promoted to meter- which happens with 
> different name: clearly the different name method has become promoted, 
> implements the different namer interface and is non-nil.
>
> I still don't fully understand why this doesn't work for equal name. If 
> impl's equal name method does get promoted it should implement the interface 
> since meter now as a equal name method. If it doesn't (due to name conflict 
> with the embedded equal name interface) where would still be the embedded 
> equal name interface (which might be nil but still existing)?

As you say, if the EqualName method were promoted it would conflict
with the existing field of type EqualName. Therefore, it is not
promoted. Therefore, meter does not have a method named EqualName. It
has a field named EqualName instead. Therefore, meter does not
implement the interface EqualName. It doesn't have a method EqualName,
so there is no way that it could implement the interface EqualName.

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 visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcWf31G9fDT96qPfcPdnZhFXnYTvzpZpW_cYjAT_oAk0SA%40mail.gmail.com.

Reply via email to