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

Imperatorn johan_forsberg_86 at hotmail.com
Tue Sep 22 17:46:07 UTC 2020


On Tuesday, 22 September 2020 at 15:22:21 UTC, Dennis wrote:
> 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.

Well, what about determinism, reasoning about halting, real-time 
contexts, time sharing, functional safety, async/await control, 
FSM constraints, resource management,..., etc

Well, strictly not bottom type, but it could be related,like 
(pseudo-code) @timeout(500.msecs, doSomething(), return something)


More information about the Digitalmars-d mailing list