3 ms·
interface{}
by wtf_is_up 12y ago
interface{}
- bluecalm 12y agoI was responding to a comment claiming that Go is better than C in discussion about generic programming. I pointed out that C in fact supports generic programming (actually by void pointers and function pointers). Why you (and other downvoters) respond with the way to do it in Go isn't quite clear to me. I didn't claim anything about Go. I claimed something about C.
- pjmlp 12y agoMaybe because Go's approach, although lacking, is still better than C in terms of type safety. When you cast from void* to whatever type, the compiler will happily accept it and bad things will happen if the type is wrong. Maybe not right away, thus the program will bleed with corrupt memory. With Go when you cast to the wrong type, a cast violation will occur and the program will panic right away.
- masklinn 12y agoI think that's memory-safety rather than type-safety: in Go (or Java or C#) the types may not be correct (so it's not type-safe) but it'll fault at runtime rather than possibly corrupt memory as C would.