On 12/10/2013 07:26 PM, Walter Bright wrote:
On 12/10/2013 1:58 AM, Timon Gehr wrote:
Recovering all immutable and const qualifiers that are possible to
assign to the program is simple to do if the whole program is available.

I believe you are seriously mistaken about it being simple, or even
possible.
...

Unfortunately I'm not currently in a position to invest any time into implementing mutability analysis for C code. Maybe later. It might prove interesting to see how well a straightforward inference of D-style qualifiers works for existing code bases. (But this is not the relevant question here since we are talking about _inherent_ advantages.)

For example, malloc() returns a pointer. How do you know if that returns
a pointer to immutable data or not? Even if it could look at the source
code to malloc()?


Malloc is part of the language runtime. Everything needed is known about it, in particular that it is pure (in the D sense). Also, the source code of malloc will not be standard C code.

In any case, please understand that giving even a valid example of a case where such an approach cannot do well (e.g. all variables under consideration are actually mutated) does not invalidate the statement made.

Reply via email to