Best practices of using const
Atila Neves
atila.neves at gmail.com
Tue Feb 19 15:30:22 UTC 2019
On Wednesday, 13 February 2019 at 16:40:18 UTC, H. S. Teoh wrote:
> On Wed, Feb 13, 2019 at 11:32:46AM +0000, envoid via
> Digitalmars-d-learn wrote:
>> [...]
>
> Const in D is very restrictive because it's supposed to provide
> real compiler guarantees, i.e., it's statically verifiable that
> the data cannot be changed.
>
> [...]
I keep hearing how const is nigh unusable in D, and except for
ranges I litter my code with const everywhere, pretty much just
as often as I used in C++. I normally only use `auto` for return
types and input ranges, and nearly all of my function parameters
are `in`.
It's true that a lot of people don't use `const` because I keep
finding and filing bugs in dub libraries as soon as I try using
them, but other than that: const is fine.
More information about the Digitalmars-d-learn
mailing list