Getting action on your favorite D issues
David Gileadi
gileadisNOSPM at gmail.com
Sat Jun 6 00:33:03 UTC 2020
On 6/5/20 5:25 PM, H. S. Teoh wrote:
> On Fri, Jun 05, 2020 at 04:53:28PM -0700, H. S. Teoh via Digitalmars-d wrote:
>> On Fri, Jun 05, 2020 at 11:57:39PM +0200, ag0aep6g via Digitalmars-d wrote:
>> [...]
>>> 2) "bool can be both true and false"
>>> https://issues.dlang.org/show_bug.cgi?id=20148
>>>
>>> This one is just silly.
>> [...]
>>
>> Nah, it's not silly, it's just that DMD's backend produces code that
>> exhibits quantum uncertainty:
> [...]
>
> For even more quantum fun:
>
> ----------
> bool schrodingersCat() @safe {
> import std.random;
> union Box { bool b; int state; }
> Box u;
> u.state = uniform(2, int.max);
> return u.b;
> }
> void main() @safe {
> import std.stdio;
> bool b = schrodingersCat();
> if (b) writeln("alive");
> if (!b) writeln("dead");
> }
> ----------
>
> With LDC, this code will output either "alive" or "dead" with a roughly
> 50% probability of each. So it's a classical observer.
>
> With DMD, however, this code will perceive the quantum superimposition
> directly and output both "alive" and "dead" every time.
>
> :-D
>
> //
>
> OK, I'll stop now. :-P
>
>
> T
>
These two posts made me very amused. Thank you.
More information about the Digitalmars-d
mailing list