First Impressions!

Jack Stouffer jack at jackstouffer.com
Tue Nov 28 16:14:52 UTC 2017


On Tuesday, 28 November 2017 at 03:01:33 UTC, A Guy With an 
Opinion wrote:
> - Attributes. I had another post in the Learn forum about 
> attributes which was unfortunate. At first I was excited 
> because it seems like on the surface it would help me write 
> better code, but it gets a little tedious and tiresome to have 
> to remember to decorate code with them. It seems like most of 
> them should have been the defaults. I would have preferred if 
> the compiler helped me and reminded me. I asked if there was a 
> way to enforce them globally, which I guess there is, but I 
> guess there's also not a way to turn some of them off 
> afterwards. A bit unfortunate. But at least I can see some 
> solutions to this.

Attributes were one of my biggest hurdles when working on my own 
projects. For example, it's a huge PITA when you have to add a 
debug writeln deep down in your call stack, and it ends up 
violating a bunch of function attributes further up. Thankfully, 
wrapping statements in debug {} allows you to ignore pure and 
@safe violations in that code if you compile with the flag -debug.

Also, you can apply attributes to your whole project by adding 
them to main

void main(string[] args) @safe {}

Although this isn't recommended, as almost no program can be 
completely safe. You can do it on a per-file basis by putting the 
attributes at the top like so

@safe:
pure:


More information about the Digitalmars-d mailing list