Discussion Thread: DIP 1034--Add a Bottom Type (reboot)--Final Review

Dennis dkorpel at gmail.com
Tue Sep 22 15:22:21 UTC 2020

On Tuesday, 22 September 2020 at 12:44:14 UTC, Imperatorn wrote:
> I have one (very) general comment. Since we are talking about 
> the halting problem, completeness etc. Since time is in essence 
> the problem, would it be possible to annotate a function with a 
> timeout (physical or virtual time) which leads to the bottom 
> type if exceeded? This could in theory be very useful.

I have trouble picturing what you're suggesting.
You mean something like this?

import std;
@timeout(500.msecs) int computeSum(int[] arr) {
     int result = 0;
     foreach(v; arr) result += v;
     return result;

void main(string[] args) {
     int result = computeSum(args[1..$].map!(to!int).array);

     // the program will now crash with `assert(0)` if computeSum
     // did not complete in under half a second?

     writeln(result); // otherwise print result

I don't see when that's ever useful or why you need a bottom type 
to do that.

More information about the Digitalmars-d mailing list