What are the unused but useful feature you know in D?

Mike via Digitalmars-d digitalmars-d at puremagic.com
Sun Jun 25 17:38:21 PDT 2017


On Sunday, 25 June 2017 at 23:21:25 UTC, aberba wrote:
> Can you share feature(s) in D people are not talking about 
> which you've found very useful?

In my experience, using appropriate attributes for functions, 
variables, etc... doesn't happen like it should.  This includes 
attributes like `@safe`, `immutable`, `pure`, `const`, and others.

I recently watched of video where Andrei acknowledged this when 
talking about the `pure` attribute 
(https://youtu.be/WsgW4HJXEAg?t=3052).  It was also acknowledged 
somewhat by Walter in his talk at DConf 2017 
(https://youtu.be/iDFhvCkCLb4?t=2531).  As I understand it, 
though, the D compiler has some logic to automatically infer some 
of these attributes, but because its *invisible* to the user it's 
difficult to predict what those inferences are, and there's no 
documentation that I'm aware of that defines how/where/where this 
happens.

IMO, part of the problem is that D has the wrong defaults (e.g. 
`immutable` by default, `@safe` by default, `final` by default, 
etc...), so users have to opt in to these things when they should 
really only be opting out of them.  Unfortunately, changing this 
would be disruptive and will probably never happen without a fork.

Mike




More information about the Digitalmars-d mailing list