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

Casting to/from empty interfaces is kind of doing the same thing for void* pointers in C, right?


No, for once, Go doesn't have casting, it has type conversions, but they are type safe. With void * you can do anything, with interface{} you can only use the dynamic types inside the interface.

That being said, using interface{} for unions is extremely unfortunate. The bright side is that after 4 years of using Go almost exclusively, I only had to abuse interface{} only once, with compiler parsers (like the parent says). Every other time there was a better design which did not require using interface{}.




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

Search: