Note: I may have chosen the wrong word in the title; perhaps I\'m really talking about polynomial growth here. See the benchmark
Accessing a new type causes the runtime to recompile it from IL to native code (x86 etc). The runtime also optimizes the code, which will also produce different results for value types and reference types.
And List
clearly will be optimized differently than List
.>
Thus also EmptyStack
and NonEmptyStack
and so on will be handled as completely different types and will all be 'recompiled' and optimized.
(As far as I know!)
By nesting further layers the complexity of the resulting type grows and the optimization takes longer.
So adding one layer takes 1 step to recompile and optimize, the next layer takes 2 steps plus the first step (or so) and the 3rd layer takes 1 + 2 + 3 steps etc.