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

Could you share a very small code snippet describing what you mean by bound method pointers?

(Huge fan of rclone!)



Something like this: https://go.dev/play/p/AVVz0qs2i1e

This is much less convenient than using interfaces directly when that is possible, but comes with a lot more power. You have more insight into the "interface" value, you can use this to manually implement prototype-like behavior as seen in Javascript, you can deliberately make an object where one "method" is invoked on one object and one "method" is invoked on another, which is hard to read but may be just what you need in some situation, etc.

There are a lot of ways to improvise on this tune.

Also note most OO or OO-flavored languages can do this, Go has no special claim to it. But the tradeoffs are pretty similar in all those languages... you want to be sure this is what you need before you use it, because the design costs are significant.




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

Search: