|
|
|
|
|
by zaphar
5193 days ago
|
|
The interface{} is a contributor to the hole but not the cause. The hole occurs when I want to make a generic container like say a binary tree. I can create a node interface that satisfies my needs for a binary tree. What I can't do is guarantee that at compile time every element in my container is of the type that I expect. If they ever add generics of some sort this hole will be closed. It's a very tiny one and can usually be limited to a single functions scope but it still exists and certainly not enough to make me dismiss the languange out of hand. You can see examples of the hole by looking at Go's container/* packages. Some of them had a completely separate implementation for each of the primitive types. Type assertions ensure type safety at runtime provided the programmer does their job. But it depends on the programmer doing their job so it could be better. Go and ML were two examples that come the closest to my "ideal" language. Go just happens to be one that I have the greatest chance of actually using in a job :-) |
|
container/* is a bit of a corner case which is rarely used, specially since append() was added to the language and container/vector was deprecated I can't remember the last time I needed anything from container/*.