Is there any real reason to use "const"?

bauss jj_1337 at
Tue Jan 25 10:42:35 UTC 2022

On Monday, 24 January 2022 at 10:23:14 UTC, rempas wrote:
> On Monday, 24 January 2022 at 10:13:02 UTC, rikki cattermole 
> wrote:
>> If you are working with raw pointers, you need a way to 
>> express read only memory.
>> Because the CPU does have it, and if you tried to write to it, 
>> bye bye process.
> We would try to avoid working with pointers directly in 
> read-only memory but in any case, I still think that the 
> programmer should know what they are doing.

Sure thing but that's not realistic if you work professionally as 
you might be handed code that 15 other people worked on for a 
decade before you.

You will not be able to reason about the memory properly, in 
which case if certain variables are marked with const it will 
tell future people that this is read-only memory.

More information about the Digitalmars-d mailing list