Is there any real reason to use "const"?
rempas at tutanota.com
Mon Jan 24 10:23:14 UTC 2022
On Monday, 24 January 2022 at 10:13:02 UTC, rikki cattermole
> 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.
The problem you described is why most language use a "string"
type that is immutable (in case you point to a string literal)
but they also have a way to allow you to modify a "string" type
in case you have allocated memory. So it's always up to you.
So that's how I see it and I can't see it going wrong. I mean,
you will properly read documentation and learn the language
right? Well that was sarcastic... no one properly reads
documentation these days which is the reason why programmers do
all these stuff bringing all the downsides along. I think we
should not reward people that don't want to properly learn the
At the same time I understand that a lot of languages don't have
a proper tutorial (book, say it however you want) to teach people
about the language. Some don't even have a full language/library
reference so even advanced programmer that want to dig cannot
learn the language. So they can't blame people for not knowing
the language in the end but this is the language creators fault
to begin with and I don't plan on doing that. I will make sure
that people can have learning the language.
More information about the Digitalmars-d