DIP 1028---Make @safe the Default---Community Review Round 1

Basile B. b2.temp at gmx.com
Thu Jan 9 03:06:59 UTC 2020


On Thursday, 9 January 2020 at 02:34:37 UTC, H. S. Teoh wrote:
> On Thu, Jan 09, 2020 at 12:01:39PM +1000, Manu via 
> Digitalmars-d wrote:
>> On Thu, Jan 9, 2020 at 10:49 AM H. S. Teoh via Digitalmars-d 
>> <digitalmars-d at puremagic.com> wrote:
> [...]
>> >         auto myFunc() @safe {
>> >                 ... // mundane stuff
>> >                 () @trusted {
>> >                         // dangerous stuff goes here
>> >                 }();
>> >                 ... // more mundane stuff
>> >         }
>> >
>> > But it's quite the eyesore, I'll admit.
> [...]
>> Lambdas are usually suggested, but it's a completely 
>> unacceptable hack.
>>  * additional function call overhead
>>  * influences the inliner heuristics unfavourably
>>  * may allocate a closure if you're not careful
> [...]
>
> Oh? Didn't somebody post a PR to inline these lambdas when they 
> appear in such contexts?  Was that never merged, or is it only 
> active with -inline?  Did you check the output asm to see what 
> it actually does?
>
>
> T

I have a feature branch with a POC [1] of @trusted block 
statements. I remember that while it worked this was not so 
nicely done because safety is something that works at the 
function level so the semantic part consists of a cheat.

[1]: https://c.gmx.com/@558129942915716568/BZ_xc2wjRgWzo3XVZXjVVg


More information about the Digitalmars-d mailing list