On Monday, 9 September 2019 at 09:37:25 UTC, a11e99z wrote:
cuz throwing exception ever is not compatible with any return type so I dont see reasons do not allow such expressions

A throw statement can actually be seen as an expression returning a 'never' / 'bottom' type which is implicitly convertible to any return type. This is actually a really good example for the value of a bottom type as suggested in DIP1017:
https://github.com/dlang/DIPs/blob/master/DIPs/rejected/DIP1017.md

Such a shame it got rejected in favor of ugly 'no return' annotations, if only the DIP pointed out other use cases. Looking at the Formal Assessment section: "He (Walter Bright) still thinks there is value in adding a bottom type to the language, but has decided to revisit the issue at a later date."

I hope a bottom type resolves this issue with throw statements in lambdas instead of another hack such as 'no return'.

Reply via email to