Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

He speaks about non-local receivers.

You can't have:

func (r *otherPackage.Receiver) method(arg int)



What's the issue with composing a new type that has otherPackage.Receiver in it, and defining the new method on the new type?


For me there is no issue.


I'm guessing: you still can't access unexported members (private vs Public).


The question could be asked the opposite: why is the new type necessary?


Because if you allow non-local method declarations, you have a ton of stuff to think about:

- Are these methods exported?

- If yes, how do you import them? Explicitly or implicitly?

- Given a method call, how can the developer tell where it was defined? How can she know if the same method call is available when using the same library in some other project? Remember that not everyone uses IDEs.

- etc.

I can see why the Go designers decided that it's just not worth it. I've seen how you turn a language into a mess with non-local method declarations (cough Ruby cough).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: