Question about math.pi is mutable

Random832 random832 at fastmail.com
Sun Nov 8 01:29:11 EST 2015


Steven D'Aprano <steve at pearwood.info> writes:
> Surely that is obvious? I don't speak much C, but I would expect that inside
> the functions, const parameters can be read, but not assigned to. "*const"
> is a mystery to me though.

There's a program (and now a website) called cdecl that can decode these:

char *const envp[]
declare envp as array of const pointer to char

In other words, the pointers in the array are const, but the array
itself (which is really a pointer, and it's generally regarded as
nonsense to make const first-level function arguments anyway, but enough
of that) is not, nor are the characters that the pointers point to.

There are various reasons I don't fully understand and are beyond the
scope of this argument regarding why it's not possible to assign a
pointer-to-pointer-to-char to a pointer-to-pointer-to-const-char, so the
argument isn't declared with the latter.

Unfortunately, while it handles simple function arguments, it (the
version on the website at least) apparently can't handle named or const
function arguments, otherwise you could paste the whole thing.




More information about the Python-list mailing list