On Mon, Jul 14, 2014 at 9:17 AM, Jonathan S. Shapiro <[email protected]>
wrote:
>
> Documentation is important, but readability is also important. Whether
> types help with readability is a matter of taste. I personally don't find
> that:
>
> arith 'a =>
> fun add x : 'a y : 'a is x + y
>
>

> is clearer than
>
> fun add x y = x + y
>
>
I'm dubious of these trivial examples. When this function is 400 lines long
and not trivial, the former is essential. First for documentation, but also
to guard forward compatibility of all users of the function. Without a
constraint like 'arith', the next programmer extending the function thinks
it's fine to start requiring lots of other things of the input types
because HIS/HER input types include them.

This type of planning is what strikes the balance between over-constraint
and under-constraint. Make the function constrained to types that can only
"+" and the function can't be extended compatibly in the future. Constrain
the type too little, and it becomes less useful.

These types of issues don't matter when there is 1 programmer, but when
there are 10,000 relying on a piece of code, it becomes essential.
_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev

Reply via email to