Why are lambda expressions not “interned”?

前端 未结 6 922
-上瘾入骨i
-上瘾入骨i 2021-01-01 19:22

Strings are reference types, but they are immutable. This allows for them to be interned by the compiler; everywhere the same string literal appears, the same objec

6条回答
  •  我在风中等你
    2021-01-01 19:58

    This is allowed because the C# team cannot control this. They heavily rely on the implementation details of delegates (CLR + BCL) and the JIT compiler's optimizer. There already is quite a proliferation of CLR and jitter implementations right now and there is little reason to assume that's going to end. The CLI spec is very light on rules about delegates, not nearly strong enough to ensure all these different teams will end up with an implementation that guarantees that delegate object equality is consistent. Not in the least because that would hamper future innovation. There's lots to optimize here.

提交回复
热议问题