Labelled @nogc Working With Inner Scopes

Ali Çehreli acehreli at yahoo.com
Mon Aug 30 20:58:01 UTC 2021


I don't have a strong opinion on the question but I tend to agree with 
the current behavior because it's easy to add the attributes anyway.

Going off topic, I want to mention that the 'in' and 'out' contracts 
have a simpler syntax now and that the 'do' (or 'body') keyword is 
optional in that place:

struct Dummy
{
// ...

   this(int memberInt, string memberStr) nothrow
   in (memberInt > MAX_MEMBER_INT, "You can put a message here")
   out (; this.memberInt == memberInt, "etc.")
   out (; this.memberStr == memberStr, "etc.")
   {
     this.memberInt = memberInt;
     this.memberStr = memberStr;
   }
}

I am reminded that the semicolons in the 'out' contracts are necessary 
even for a function that does not return a value (like a constructor 
does not).

Ali



More information about the Digitalmars-d-learn mailing list