I’d like to see the unit tests for the non-true return state.
turn_computer_off();
Assert(!is_computer_on(), "Computer should have been off but it's on.");
The opposite is a bit tricky, though.
51–60 of 197 posts
I’d like to see the unit tests for the non-true return state.
turn_computer_off();
Assert(!is_computer_on(), "Computer should have been off but it's on.");
The opposite is a bit tricky, though.
> If the computer isn't on, the value returned by this function is undefined. Shouldn't it just block until the computer turns back on? Probably interferes with pthreads.
Seems like a reasonable compiler would inline the most likely implementation as 1. So, while technically undefined, it's safe to assume that it will 'return' 1 regardless of the actual on/off state of the computer.
[1] https://github.com/haiku/haiku/commit/ccaac177f64038c160de6f...
Earlier quoted context omitted.
Seems like a reasonable compiler would inline the most likely implementation as 1. So, while technically undefined, it's safe to assume that it will 'return' 1 regardless of the actual on/off state of the computer.
{return 1;} is clearly a faulty implementation, it's entirely possible that the computer is already turned off by the time the function is executed using power stored in the decoupling capacitors of the CPU.
> If the computer isn't on, the value returned by this function is undefined. Shouldn't it just block until the computer turns back on? Probably interferes with pthreads.
Hmm, it seems like you need to make sure the computer is on before calling this function, or else you run the risk of getting back undefined data. Seems like we also need a function that can be used to tell if the computer is on...
I like how it also has support for the ENIAC platform. I kicked my family out of the house so I had room to install the ENIAC. Happy to hear there's an OS I can run on it to get real work done, like posting unfunny jokes for strangers on Hacker News.
Earlier quoted context omitted.
There's an elegant FP solution that involves searching an infinite data structure using only a finite amount of computation -- actually, with precisely zero computation, because the machine isn't on. It's like lazy evaluation, only more lazy.
Wait. When the machine isn't on, P=NP! So our security systems are (useless | perfect)! I think there might even be other implications...
(How could this work in theory? Maybe the computer has a separate watchdog controller board which allows the computer to be turned on and off remotely, and that controller acts as a proxy for the API request.)