Lies in education [was Re: The "loop and a half"]
Bill
BILL_NOSPAM at whoknows.net
Thu Oct 12 03:48:25 EDT 2017
Marko Rauhamaa wrote:
> Grant Edwards <grant.b.edwards at gmail.com>:
>
>> I like [const qualifiers] in C because it allows the linker to place
>> them in ROM with the code. It also _sometimes_ provides useful
>> diagnostics when you pass a pointer to something which shouldn't be
>> modified to something that is going to try to modify it.
> Unfortunately, "const" is so tacky in practice that the language and the
> standard libraries have rendered it useless.
>
> One example is the surprising fact that string literals in C are "char
> *" and not "const char *".
If not, you couldn't pass a string literal to a function having prototype
void f(char *s);
Of course, if f tries to modify *s, there will be a run time error as
character string literals are stored in a "special place", and are not
mutable. This improves performance.
More information about the Python-list
mailing list