@trusted AKA most useless statement ever

2016-11-25 Thread Satoshi via Digitalmars-d
Simply, it should be replaced by: void safeFunc() @safe { unsafe { auto vi = doUnsafeCall(); } } @trusted functions are prohibited by d-idiom (so I don't know why are still in D). So, when I need to create a simple window with OpenGL context I need to write about 10-15 calls to

Re: @trusted AKA most useless statement ever

2016-11-25 Thread Stefan Koch via Digitalmars-d
On Friday, 25 November 2016 at 10:14:46 UTC, Satoshi wrote: Simply, it should be replaced by: void safeFunc() @safe { unsafe { auto vi = doUnsafeCall(); } } @trusted functions are prohibited by d-idiom (so I don't know why are still in D). So, when I need to create a simple win

Re: @trusted AKA most useless statement ever

2016-11-25 Thread Adam D. Ruppe via Digitalmars-d
On Friday, 25 November 2016 at 10:14:46 UTC, Satoshi wrote: but writing 20 times something like: auto vi = (() @trusted => glXChooseXFBConfig(...))(); That's an anti-pattern and you should almost never actually do it. That is breaking the trusted thing, and is not what the blog means when it

Re: @trusted AKA most useless statement ever

2016-11-25 Thread Andrei Alexandrescu via Digitalmars-d
On 11/25/16 5:14 AM, Satoshi wrote: void safeFunc() @safe { unsafe { auto vi = doUnsafeCall(); } } How would this work for marking C functions assumed to be safe as trusted? -- Andrei

Re: @trusted AKA most useless statement ever

2016-11-25 Thread Guillaume Piolat via Digitalmars-d
On Friday, 25 November 2016 at 10:14:46 UTC, Satoshi wrote: @trusted functions are prohibited by d-idiom (so I don't know why are still in D). Uh? No. I wonder where you've read this.

Re: @trusted AKA most useless statement ever

2016-11-25 Thread Adam D. Ruppe via Digitalmars-d
On Friday, 25 November 2016 at 15:01:43 UTC, Andrei Alexandrescu wrote: How would this work for marking C functions assumed to be safe as trusted? -- Andrei You'd presumably just mark the prototypes as @safe too.

Re: @trusted AKA most useless statement ever

2016-11-25 Thread Steven Schveighoffer via Digitalmars-d
On 11/25/16 5:14 AM, Satoshi wrote: Simply, it should be replaced by: void safeFunc() @safe { unsafe { auto vi = doUnsafeCall(); } } @trusted functions are prohibited by d-idiom (so I don't know why are still in D). No, they are not. @trusted escapes are for use when you can r

Re: @trusted AKA most useless statement ever

2016-11-25 Thread Andrei Alexandrescu via Digitalmars-d
On 11/25/16 10:30 AM, Adam D. Ruppe wrote: On Friday, 25 November 2016 at 15:01:43 UTC, Andrei Alexandrescu wrote: How would this work for marking C functions assumed to be safe as trusted? -- Andrei You'd presumably just mark the prototypes as @safe too. Hmmm... ok, that would work by means

Re: @trusted AKA most useless statement ever

2016-11-25 Thread Adam D. Ruppe via Digitalmars-d
On Friday, 25 November 2016 at 16:03:27 UTC, Andrei Alexandrescu wrote: Hmmm... ok, that would work by means of the convention "@safe + no implementation really means trusted". Not too convenient I'd say. -- andrei It works today, though. The compiler will allow you to put @safe with no body

Re: @trusted AKA most useless statement ever

2016-11-25 Thread Kagamin via Digitalmars-d
On Friday, 25 November 2016 at 10:14:46 UTC, Satoshi wrote: but writing 20 times something like: auto vi = (() @trusted => glXChooseXFBConfig(...))(); or: auto vi = () @trusted { return glXChooseXFBConfig(...); }(); Trusted blocks are used for safety inference in generic code, so that only co

Re: @trusted AKA most useless statement ever

2016-11-25 Thread Kagamin via Digitalmars-d
On Friday, 25 November 2016 at 16:03:27 UTC, Andrei Alexandrescu wrote: Hmmm... ok, that would work by means of the convention "@safe + no implementation really means trusted". Not too convenient I'd say. @trusted means "@safe interface, @system implementation", so when you have only interfac