On 2011-02-04 20:33, Walter Bright wrote:
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.

This is quite interesting, I generally agree with this but on the other hand Ruby on Rails is basically built on conventions, it works out very well and I love it. For example:

The class "FooBar" matches the table "foo_bars".

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.


--
/Jacob Carlborg

Reply via email to