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

>Trivial example: you want to build a container that can hold data of different types and perform generic operations on them.

Do I?

I would simplify the problem to not need different types or generic operations.

Or if I really need generic operations, break them down to smaller operations so you don't need to take a bunch of type parameters everywhere.

For example containers, instead of having container<T>, have the container operations return an index or 'opcode', then the user applies that to their data. The container doesn't need to know about T, void pointers or sizes, just its own internal bookkeeping stuff.



That's valid, even sensible, but you have now left significant performance on the table.




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

Search: