开发者

Tailcall parameter in Expression.Lambda

开发者 https://www.devze.com 2023-03-29 15:07 出处:网络
What is the reason behind giving a parameter for tailcall optimization in Expression.Lambda(Expression body,bool tailcall,

What is the reason behind giving a parameter for tailcall optimization in

Expression.Lambda(Expression body,bool tailcall,
IEnumerable<ParameterExpression> Parameters)

As long 开发者_StackOverflowas it is not going affect the result why do we explicitly need to specify a value for it.And i feel it is always better to have tailcall optimization. Do you have different thought on this


The design is kinda funny.

Passing true for the tailcall parameter, will attempt to call method in a tail position as a tail call within the body of the lambda.

A tail position is where a method call is the expression being returned.

As for better, that is subjective.

  • Tail calls tend to be always slower
  • There are certain rules to follow (return types must match or be references)
  • You have no stacktrace for debugging
0

精彩评论

暂无评论...
验证码 换一张
取 消