Is there any real reason to use "const"?
forkit
forkit at gmail.com
Tue Jan 25 03:41:34 UTC 2022
On Monday, 24 January 2022 at 10:06:49 UTC, rempas wrote:
> ..
> What do you guys think?
Well, if const were default, you could ask yourself, is there any
real reason to use mutable :-)
If I see a function: void getuser(string pwd){} .. I get kinda
concerned.
If I write a function: void getuser(string pwd){} .. I also get
kinda concerned.
After hours of debugging, you eventually realise the root of your
problem, was that pwd was not const.
Constraints on parameters help to ensure correctness. That is the
value of const.
I wish @safe and const were default actually.
More information about the Digitalmars-d
mailing list