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



I thought this kind of magic code was explicitly what go creators didn't want.

If i compare to Objective-C "object respondsToSelector:selector()" or "object isKindOfClass" equivalent, this go "casting to an anonymous struct" code seems extremely convoluted.

Plus, i may be wrong, but it seems like it's really not robust. You're trying to cast to an anonymous struct declared locally, that isn't linked to any other interface anywhere, and only implements part of the methods defined in the File struct. It's looks to me just as robust as using strings. What you would like to express, is what's in the comment : aka, test against something related to the File struct/interface.


There are no anonymous structs in that slide, just anonymous interfaces.


Indeed, i think my point still hold though




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

Search: