Re: Very simple null reference escape

2019-06-02 Thread Basile B. via Digitalmars-d-learn
On Sunday, 2 June 2019 at 07:55:27 UTC, Amex wrote: A.B If A is null, crash. A?.B : writeln("HAHA"); No crash, ignored, equivalent to if (A is null) writeln("HAHA"); else A.B; safeAccess from iz does this : https://github.com/Basile-z/iz/blob/master/import/iz/sugar.d#L1666

Re: Very simple null reference escape

2019-06-02 Thread Amex via Digitalmars-d-learn
On Sunday, 2 June 2019 at 14:37:48 UTC, Paul Backus wrote: On Sunday, 2 June 2019 at 07:55:27 UTC, Amex wrote: A.B If A is null, crash. A?.B : writeln("HAHA"); No crash, ignored, equivalent to if (A is null) writeln("HAHA"); else A.B; The "optional" package on dub [1] has a .dispatch

Re: Very simple null reference escape

2019-06-02 Thread Paul Backus via Digitalmars-d-learn
On Sunday, 2 June 2019 at 07:55:27 UTC, Amex wrote: A.B If A is null, crash. A?.B : writeln("HAHA"); No crash, ignored, equivalent to if (A is null) writeln("HAHA"); else A.B; The "optional" package on dub [1] has a .dispatch method that does this: auto d = some(A()); //

Very simple null reference escape

2019-06-02 Thread Amex via Digitalmars-d-learn
A.B If A is null, crash. A?.B : writeln("HAHA"); No crash, ignored, equivalent to if (A is null) writeln("HAHA"); else A.B;