3 ms·
> This is a blanket assertion. Why should useful semantics require generics? Why can't they come with simple fixed data structures? What do you mean by "fixed
by dmitriid 5y ago
> This is a blanket assertion. Why should useful semantics require generics? Why can't they come with simple fixed data structures?
What do you mean by "fixed data structures"?
> If you can provide a nice counterexample to the example that I gave
I may be missing somehing but I don't understand your example. The idea of a list is that we want it to hold any data, so the API to a list by necessity becomes generic. Unless you cas everything to void*.
---
I have another counterexample from userspace. Our internal APIs all use the same converntions which make working with them predictable and same from any language. An API returns:
{
result: [a list of data],
nextPageToken:
}
Different APIs will of course have different data. Some API will return a list of contracts. Another API will retur a list of media. A third API will... etc.
I had the misfortune of working with these APIs in Go before generics. Welcome to copy-pasting code that deals with this. Or cast from interface{}/void* to proper data in runtime. Any sane language of course lets you write something like GetAllData<T>()