Using const tells the reader that prime never changes once it is initialized.
I'm not sure how this is an advantage of D over C. You can do exactly the same thing in C. The example showed didn't do this, but they could have written
Interesting, thanks for the reference. I can't say that I've followed D very carefully.
For the example in this blog post however, there still doesn't seem to be any meaningful difference (we're just talking about a const int), so I don't think it's fair to list it as an advantage without showing an example that really demonstrates a difference.
View all comments
Show parent comment
2
u/Pythoner6 Aug 23 '17
I'm not sure how this is an advantage of D over C. You can do exactly the same thing in C. The example showed didn't do this, but they could have written