proposed @noreturn attribute

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Sat Jul 8 15:12:19 PDT 2017


On 7/8/2017 1:20 PM, H. S. Teoh via Digitalmars-d wrote:
> Hmmm. Just to clarify, what exactly does @noreturn include? If I have a
> function that calls exit(), that's @noreturn? What about a function that
> always throws? Or a function that calls exec()? A function that always
> ends in assert(0)? A function that context-switches to a different
> thread / fibre and terminates this one?

There's no subtlety to it. It's a function that never returns. I.e. it doesn't 
execute a 'RET' instruction.


> 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.

It would be like `size_t`.


More information about the Digitalmars-d mailing list