D vs nim

Arun Chandrasekaran aruncxy at gmail.com
Thu Mar 29 03:57:05 UTC 2018


On Tuesday, 27 March 2018 at 23:23:10 UTC, Timothee Cour wrote:
> that comment was regarding -betterC
> RAII (with structs) has been available in D for a while, eg:
>
> ```d
> struct A{
>   ~this(){...}
> }
>
> void fun(){
>   A a; // when a goes out of scope, will call dtor 
> deterministically
> }
> ```
>
>
> On Tue, Mar 27, 2018 at 4:15 PM, Ali via Digitalmars-d 
> <digitalmars-d at puremagic.com> wrote:
>> On Tuesday, 27 March 2018 at 01:19:44 UTC, timotheecour wrote:
>>> [...]
>>
>>
>> How is RAII available in D? I did a quick search on this forum 
>> but didnt exactly find what I want
>>
>> I found a comment for Walter (saying it was recently added 
>> https://forum.dlang.org/post/p1pa01$kc8$1@digitalmars.com)
>>
>> What was the added feature that now enables RAII in D

This is deterministic destruction and not RAII. Resource is never 
*acquired* here. Lack of default constructors for struct in D 
makes it impossible to achieve the RAII as in C++.


More information about the Digitalmars-d mailing list