Why is it not possible to evaluate lambdas in the immediate window?

后端 未结 5 1174
没有蜡笔的小新
没有蜡笔的小新 2021-02-07 03:36

Is there any particular reason? Is it not possible at all or is it just not implemented yet? Maybe there are any third-party addins that allow lambda evaluations?

5条回答
  •  生来不讨喜
    2021-02-07 04:13

    Well, I think it's because the immediate window can only evaluate expressions, or rather it can only do invocations and assignments. To evaluate a Lambda expression a closure would have to be created for that lambda, typchecked and then executed.

    I think it comes down to that the Immediate window is just an evaluator and not an interpreter.

    http://msdn.microsoft.com/en-us/library/f177hahy(VS.80).aspx

    "The Immediate window is used at design time to debug and evaluate expressions, execute statements, print variable values, and so forth. It allows you to enter expressions to be evaluated or executed by the development language during debugging."

    So in effect, your question boils down to why you can't define functions in the immediate window (since lambdas are just annonymous functions), and the answer I think is that it simply wasn't designed for that.

提交回复
热议问题