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

后端 未结 5 1288
没有蜡笔的小新
没有蜡笔的小新 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:17

    When writing a lambda, the act of capturing variables significantly alters the construction of the underlying code (moving variables into fields of compiler-generated classes, that could very easily themselves be chained closure-contexts).

    Not even considering the general complexity of doing this, it would then have two choices:

    • capture all the variable values as constants; feasible and pretty simple, but could easily mean that the result of executing in the immediate window is very different to the result of executing in the main body (very undesirable)
    • rewrite the entire code (for the reasons outlined above) on the fly (at a guess, impossible)

    Given a choice between "undesirable" and "impossible", I guess they simply chose not to implement a feature that would be inherently brittle, and very complex to write.

提交回复
热议问题