On Friday, 9 February 2018 at 16:05:52 UTC, Ralph Doncaster wrote:
On Friday, 9 February 2018 at 15:46:56 UTC, Mike Parker wrote:
On Friday, 9 February 2018 at 15:37:12 UTC, Ralph Doncaster
I think you are proving my point. You say there is no
const MAX_IN = 20;
immutable MAX_IN = 20;
So now I have to try both, and look at the generated code to
Or read the docs:
p.s. I prefer const since it is easier for C/C++ coders to
understand. Using immutable invites the coder to go down the
whole rat hole of trying to understand how is it different
It's not a rathole. The document page above explains the
differences rather well. They only happen to be identical when
initialized with compile-time constants.
Well this part of the docs is a rathole to me:
It might be clear and simple to you, but it's not to me. And
I'm a rather advanced developer.
While there are lots of things I like about D compared to C++
such as getting rid of #include hell, there's too many "messy"
things and the learning curve is too steep for me to consider
suggesting it for any consulting projects. I think it could've
been better if there was more focus on keeping the language
(and standard library) clean and simple instead of making it
more like a swiss army knife.
The graphic is way too complicated.
Forget inout, it's seldomly used and there have even attempts to
remove it from the language.
- any type can be implicitly converted to const X
- shared can't be implicitly removed
- immutable can't be implicitly removed
There's also: https://dlang.org/articles/const-faq.html