News for hackers. Stuff that matters.
Re:How to design a replacement for C++ by saucetenuto on Thursday July 22, 2010 @11:35AM (#1538430)
> This is an oversimplification to say this but at some level generics are implemented as syntatic sugar for typecasts between Object and the type parameter type.

This is not true. Java generics work this way (google "type erasure"), but C# generics are implemented with specialized code, so that e.g. List<int>.Add has its own IL implementation distinct from the one for List<Bitmap>.Add. This lets the JIT do type-specific optimizations, like not having to box the ints in a List<int>.

The specialization code also tries to share code in cases where the type parameters don't matter (e.g. so that you don't have a million identical implementations of List.Count hanging around).

There are no comments on this comment yet.