On Sat, Jul 08, 2017 at 01:20:03PM -0700, H. S. Teoh via Digitalmars-d wrote: [...] > Personally, I'm for this. It is useful for functions that constructs > then throws an exception, for example. It would be nice to be able to > call such a function from another function that returns non-void > without having to insert assert(0) into the latter to avoid the > compiler complaining that you failed to return a value. > > As for Andrei's idea, it's pretty clever but we would need to > standardize the None type, otherwise we risk hard-to-read code when > everyone rolls their own None type with different names. An attribute > has the advantage that it will be universally understood. [...]
Also, a @noreturn attribute would allow overriding a non-void class method with a @noreturn one (e.g. the derived class is a sentinel object that forces an exception / termination upon calling that method), whereas you can't do that with a None return type because the signature would not match the base class's. T -- "Hi." "'Lo."