Question about math.pi is mutable

Grant Edwards invalid at invalid.invalid
Sat Nov 7 22:31:59 EST 2015


On 2015-11-07, Marko Rauhamaa <marko at pacujo.net> wrote:
> Grant Edwards <invalid at invalid.invalid>:
>
>> I take it you don't write embedded code that runs from ROM? I do. The
>> const keyword is the most valuable addition to the C language since
>> the function prototype. Without it, you used to have to jump through
>> all sorts of hoops to get read-only data placed into read-only memory.
>
> If all you need is a linker directive that places data in a read-only
> section, "const" is a very ineffective tool that clutters the code and
> forces you to sprinkle type casts around your code.

But it allows the compiler to warn you if you pass a pointer to a
read-only data to a function that expects a pointer to writable data.

For those of us who occasionally make mistakes, such compiler warnings
are very useful.

-- 
Grant




More information about the Python-list mailing list