std.xml should just go

Walter Bright newshound2 at digitalmars.com
Fri Feb 4 11:33:58 PST 2011


so wrote:
> It doesn't matter what signature you use for the function, compiler is 
> aware and will output an error when you do the opposite of the 
> signature. If this is the case, why do we need that signature?


Examine the API of a function in a library. It says it doesn't modify anything 
reachable through its arguments, but is that true? How would you know? And how 
would you know if the API doc doesn't say?

You'd fall back to const by convention, and that is not reliable and does not 
scale. You have to manually go through an entire hierarchy of function calls to 
figure out if one might change a member of the data structure, and then after a 
few maintenance cycles, you have to do that all over again.

Or not, and just hope for the best (which is what happens in practice).

The "why", then, is that guarantees are better than hope.


More information about the Digitalmars-d mailing list