3 ms·
Wrt/ to generics I think one interesting exercise would be to look at list and see what would need to happen such that it behaves more like the built in map. Y
by YZF 9y ago
Wrt/ to generics I think one interesting exercise would be to look at list and see what would need to happen such that it behaves more like the built in map. You'd want to be able to declare:
- list[type]
- delete should work.
- len and cap should work. (rather than .Len() )...
- range should work.
- What do we do for iterators?
I think it would make code that uses lists more readable/grokable. So you do get something in return for the debt you possibly took on to be able to implement list. In a sense that's also the way C++ trades things off, the library code is more difficult but the code using the library is simpler/safer.